小编ski*_*kip的帖子

圆形视图路径

我正在使用Spring MVC 3,我正在尝试做的是提交一个带有post请求的表单,并将控制器上的post请求处理程序重定向到某个页面.但是当我尝试这样做时,我收到以下错误:

javax.servlet.ServletException: Circular view path [thanks.htm]: would dispatch back to the current handler URL [/wickedlysmart/thanks.htm] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Run Code Online (Sandbox Code Playgroud)

以下是我使用的代码:

请求处理程序

@RequestMapping(method=RequestMethod.GET, value="thanks")
public ModelAndView thanks() {
    logger.debug("redirecting..");
    return new ModelAndView("thanks");
}
@RequestMapping(method = RequestMethod.POST, value="talk")
public String processContactForm(HttpServletRequest req) {      
    //...
    return "redirect:thanks";
}
Run Code Online (Sandbox Code Playgroud)

在Spring应用程序上下文中查看解析器:

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

    <property name="prefix" value="" />
    <property name="suffix" value=".htm" />

</bean>
Run Code Online (Sandbox Code Playgroud)

我不太能理解这里发生了什么.我看到"重定向..."正在记录,然后我收到此错误.有人可以帮我解决这个问题吗?

谢谢.

servlets spring-mvc http-post

5
推荐指数
1
解决办法
1万
查看次数

java.lang.ClassNotFoundException:android.R

我正在尝试使用Robolectric 2.2运行一个简单的junit测试,但我得到以下使用ADT包22错误:

java.lang.NoClassDefFoundError: android/R
    at org.robolectric.bytecode.Setup.<clinit>(Setup.java:40)
    at org.robolectric.RobolectricTestRunner.createSetup(RobolectricTestRunner.java:137)
    at org.robolectric.RobolectricTestRunner.createSdkEnvironment(RobolectricTestRunner.java:115)
    at org.robolectric.RobolectricTestRunner$3.create(RobolectricTestRunner.java:278)
    at org.robolectric.EnvHolder.getSdkEnvironment(EnvHolder.java:21)
    at org.robolectric.RobolectricTestRunner.getEnvironment(RobolectricTestRunner.java:276)
    at org.robolectric.RobolectricTestRunner.access$100(RobolectricTestRunner.java:57)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:190)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:177)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: android.R
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 24 more
Run Code Online (Sandbox Code Playgroud)

代码给出了我的错误如下:

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import …
Run Code Online (Sandbox Code Playgroud)

testing junit android robolectric

5
推荐指数
1
解决办法
2540
查看次数

如何国际化HTML页面

有没有办法基于用户区域设置国际化html页面?我有一个使用html页面开发的网站,但现在要求我用4种不同的语言将该网站国际化.

我知道如何通过资源包使用Spring Framework来实现它,但我想知道是否有办法使用HTML页面做类似的事情,这样你只需编写考虑国际化的代码,然后继续添加要选择的资源包用户访问网站时基于用户区域设置?

html spring resourcebundle internationalization

4
推荐指数
1
解决办法
5186
查看次数

尽管被观看,角度ui-router中的命名视图仍未更新

我有一个范围变量$scope.foo,我正在监视.它可以通过表单中的文本字段进行更新.

我有两个命名视图,AB在我使用angular ui-router渲染的页面上.命名视图A具有文本表单字段,正在监视控制器中的更改ng-model="foo".当foo用户更改值时$scope.bar,它会ng-repeat在命名视图的指令中使用的控制器中更改另一个作用域变量(即数组)的值B.$scope.bar使用$scope.$watch控制器中的方法进行更改.

那我现在面临的问题是,当将foo改变我可以看到的变化bar上的命名视图A,但不是在命名视图B.

有人可以帮我解决这个问题吗?

编辑: 是此问题的plunker.

javascript angularjs angularjs-scope angularjs-ng-repeat angular-ui-router

4
推荐指数
1
解决办法
2982
查看次数

如何将插值作为参数传递给angularjs中的javascript函数

我在我的angularjs应用程序中单击html按钮时调用一个函数,如下所示

<button type="button" class="btn" ng-click="foo(bar, fruits, {{user.email}})">Get it Done</button>
Run Code Online (Sandbox Code Playgroud)

foo是在控制器的功能,bar并且fruits是从表单的值和{{user.email}}在范围内的电子邮件.

我可以{{user.email}}在html页面上显示,但是当点击给定时,我在控制器undefinedfoo功能中获得了它button.

$scope.foo = function(bar, fruits, email) {
    //email is undefined here
};
Run Code Online (Sandbox Code Playgroud)

有人可以帮我理解如何将该{{user.email}}值传递给foo控制器中的函数?

html javascript arguments angularjs angularjs-ng-click

4
推荐指数
1
解决办法
3862
查看次数

Java 泛型方法的返回类型中的上限和下限通配符

我试图解决一个我无法理解部分答案的问题。

以下是课程BackLister

public class BackLister {
    // INSERT HERE
    {
        List<T> output = new LinkedList<T>();
        for (T t : input)
            output.add(0, t);
        return output;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题问哪个可以插入到// INSERT HERE类中BackLister编译运行不会出错?

以下是选项:

A. public static <T> List<T> backwards(List<T> input)
B. public static <T> List<T> backwards(List<? extends T> input)
C. public static <T> List<T> backwards(List<? super T> input)
D. public static <T> List<? extends T> backwards(List<T> input)
E. public static <T> List<? super T> backwards(List<T> input)
F. …
Run Code Online (Sandbox Code Playgroud)

java generics wildcard generic-method

4
推荐指数
1
解决办法
1150
查看次数

缺少工件org.springframework.security:spring-security-parent:jar:3.0.7.RELEASE:compile

Missing artifact org.springframework.security:spring-security-parent:jar:3.0.7.RELEASE:compilepom.xml添加maven依赖项时遇到错误Spring Security但是当我删除该依赖项时,错误消失了.有人可以帮助我理解为什么会发生这种情况,我应该如何使用maven在我的应用程序中添加Spring Security 3?谢谢.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

     <modelVersion>4.0.0</modelVersion>
     <groupId>com.think</groupId>
     <artifactId>think</artifactId>
     <packaging>war</packaging>
     <version>0.0.1-SNAPSHOT</version>  
     <name>think Maven Webapp</name>
     <url>http://maven.apache.org</url>

    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.0.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.1</org.slf4j-version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

     <dependencies> 
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-parent</artifactId>
            <version>3.0.7.RELEASE</version>
        </dependency>


        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>

        <!-- …
Run Code Online (Sandbox Code Playgroud)

spring-security pom.xml maven

3
推荐指数
1
解决办法
2万
查看次数

如何将数据从EJS模板传递到AngularJS控制器

我通过NodeJS从ExpressJS获得用户数据如下:

app.js

app.get('/user', function(req, res) {
    res.render('users', { title: 'Foo', user: req.user });
});
Run Code Online (Sandbox Code Playgroud)

users.ejs

<%= user %>
Run Code Online (Sandbox Code Playgroud)

我需要useruser.ejs上面的数据到angularjs控制器,所以我可以在其他命名视图上显示它.

有人可以帮我吗?

javascript ejs node.js express angularjs

3
推荐指数
1
解决办法
3337
查看次数

内容辅助在Eclipse中使用带有'Spring Project Nature'的Java Project的applicationContext.xml中不起作用

我有一个使用Spring 3和Hibernate 3的简单Java项目.

我使用Spring IDE添加了"Spring Project Nature".applicationContext.xml文件位于项目的src文件夹中.

Eclipse 3.5的Content Assist功能似乎在applicationContext.xml中不起作用:

  • 在bean标记的class属性中,它似乎无法在我的Java Project中找到包和类.
  • 它无法协助任何属性,例如在applicationContext.xml中查找ref属性的现有bean.

eclipse spring spring-ide

2
推荐指数
1
解决办法
9014
查看次数

是否可以在AngularJS中有条件地打开和关闭过滤器?

例如,我有一张桌子,其中我向学生展示数学,科学,英语和其他科目的标记.我有一个checkbox,如果检查只会列出有学生 {{student.mathMarks + student.scienceMarks > 150}}(即学生的数学和科学标记的总和超过150).当checkbox未经检查时,它将再次显示所有学生.有没有办法将条件过滤器与给定学生联系ng-repeat起来实现这一目标?

以下是与我上面尝试解释的案例有关的代码:

<tr ng-repeat="student in students">
    <td >
        {{student.name}}
    </td>
    <td >
       {{student.mathMarks}}
    </td>
    <td >
       {{student.scienceMarks}}
    </td>
     <td >
       {{student.englishMarks}}
    </td>
</tr>

<input type="checkbox" ng-model="onlyFooStudents" />
Run Code Online (Sandbox Code Playgroud)

checkbox conditional filter angularjs ng-repeat

2
推荐指数
1
解决办法
2298
查看次数