Spring MVC和Maven集成(Spring MVC & Maven Integration)
我正在尝试构建一个Spring MVC项目,并且在尝试解决跟随错误时遇到了一些麻烦。
HTTP状态500 - 循环视图路径[登录]:将再次调度回当前处理程序URL [/ login]。 检查您的ViewResolver设置! (提示:由于生成默认视图名称,这可能是未指定视图的结果。)
我通过终端输入以下命令:
mvn清洁包
java -jar target / sprint2-0.1.0.jar的pom.xml
<?xml version="1.0" encoding="UTF-8"?> <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.teamvirus.src</groupId> <artifactId>sprint2</artifactId> <version>0.1.0</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>0.5.0.M6</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--><dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring3</artifactId> </dependency>--> </dependencies> <properties> <start-class>com.teamvirus.src.Application</start-class> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
LoginController.java
package com.teamvirus.src; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class LoginController { @RequestMapping("/login") public String login() { return "login"; } @RequestMapping("/authenticate") public String authenticate( @RequestParam(value = "username", required = true) String username, @RequestParam(value = "password", required = true) String password) { if ((username.equals("admin") && password.equals("admin"))) return "redirect:dashboard?username=" + username; else if ((username.equals("student1") && password.equals("student1"))) { return "redirect:dashboard?username=" + username; } return "wrongpassword"; } }
感谢所提供的任何帮助。
编辑:
Application.java
package com.teamvirus.src; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
I'm trying to build a Spring MVC project and am having some troubles trying to resolve the follow error.
HTTP Status 500 - Circular view path [login]: would dispatch back to the current handler URL [/login] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
I entered the following commands via Terminal:
mvn clean package
java -jar target/sprint2-0.1.0.jarpom.xml
<?xml version="1.0" encoding="UTF-8"?> <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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.teamvirus.src</groupId> <artifactId>sprint2</artifactId> <version>0.1.0</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>0.5.0.M6</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--><dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring3</artifactId> </dependency>--> </dependencies> <properties> <start-class>com.teamvirus.src.Application</start-class> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
LoginController.java
package com.teamvirus.src; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class LoginController { @RequestMapping("/login") public String login() { return "login"; } @RequestMapping("/authenticate") public String authenticate( @RequestParam(value = "username", required = true) String username, @RequestParam(value = "password", required = true) String password) { if ((username.equals("admin") && password.equals("admin"))) return "redirect:dashboard?username=" + username; else if ((username.equals("student1") && password.equals("student1"))) { return "redirect:dashboard?username=" + username; } return "wrongpassword"; } }
Appreciate any assistance rendered.
Edit:
Application.java
package com.teamvirus.src; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.context.annotation.ComponentScan; @ComponentScan @EnableAutoConfiguration public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
原文:https://stackoverflow.com/questions/20467103
最满意答案
我们找到了解决方案,错误就在我们这边。 列创建等很好。 在某个地方,有人改变了价值类型。
We've found the solution and the mistake was on our side. Column creation etc is fine. Somewhere deep, someone has changed value types.
相关问答
更多-
Go语言规范( 地址运算符 )不允许使用数字常量的地址(不是无 类型常量或类型常量)。 操作数必须是可寻址的 ,即变量,指针间接或片段索引操作; 或可寻址结构操作数的字段选择器; 或可寻址阵列的数组索引操作。 作为可寻址性要求的例外, x [在&x ]的表达式中也可能是一个(可能为括号的) 复合文字 。 为了推理,为什么这是不允许的,请参阅相关问题: 查找常量的地址 。 一个类似的问题(同样不允许使用它的地址): 我如何在Go中存储对操作结果的引用? 你的选择(尝试Go游乐场上的所有): 1)用new() ...
-
结构与int64值(Struct vs int64 value)[2023-12-31]
如果您无法下定决心,请使用工会。 例如,微软定义了一个LARGE_INTEGER联合 。 If you can't make up your mind, use a union. Microsoft for example defines a LARGE_INTEGER union. -
pandas为什么int64 - float64列减法产生NaN's(pandas why does int64 - float64 column subtraction yield NaN's)[2022-11-01]
在这里发帖,我们可以从评论中结束这个问题: 您确定每个数据帧具有相同的索引范围吗? 您可以通过df.reset_index(drop=True)重置两个帧上的索引,然后按df.reset_index(drop=True)减去帧。 此过程应产生所需的输出。 Posting here so we can close the question, from the comments: Are you sure each dataframe has the same index range? You can rese ... -
通常,在64位浮点中存储64位整数不是保存。 您可以通过以下方式轻松查看: import numpy as np print(np.int64(2**63-1)) print(np.int64(np.float64(2**63-1)) 第一个会给你正确的结果(9223372036854775807),第二个有一个舍入错误,导致整数溢出(-9223372036854775808)。 为了理解这个,你必须看看这些数字是如何存储的。 虽然整数基本上只是将其绝对值存储为二进制数(加上一位用于数字的符号),但这不适 ...
-
这个问题没有得到广泛的认同。 使用泛型的优点是可移植性 。 同一段代码将独立于平台的字大小进行编译和运行。 在某些情况下,它也可能更快。 使用特定类型的优点是精度 。 没有模棱两可的余地,而且类型的确切功能是提前知道的。 没有硬答案。 如果您为了任何目的而坚持事情的任何一方,您迟早会发现自己是个例外。 This subject is not widely agreed upon. The advantage of using a generic type is portability. The same p ...
-
演示: In [10]: d Out[10]: {'a': [1506758000000000000, nan, 1508758000000000000]} 天真的做法: In [11]: pd.DataFrame(d) Out[11]: a 0 1.506758e+18 1 NaN 2 1.508758e+18 解决方法(注意dtype=str ): In [12]: pd.DataFrame(d, dtype=str).fillna(0).asty ...
-
PHP中的INT类型链接到CPU 和安装的PHP版本(您可以在64位CPU上安装32位PHP)。 要找出PHP可以支持的最大整数,简单地说 echo PHP_INT_MAX; 这将给你最大的收益。 它会给你20亿,或者数量太大而无法读取(9.2亿左右)。 请注意,它是签名的(20亿 - > +20亿,或-9 gazillion - > +9 gazilion)。 你可以在mySQL中指定unsigned,你在PHP中没有这个选项。 如果您只有20亿个限制,那么您安装了32位版本的PHP。 您可以在64位C ...
-
sqldf大整数(INT64)(sqldf big integer(INT64))[2022-03-31]
尝试这个: library(sqldf) # create test data Lines <- "a, b, c, d, e, f, g 0, 0, 11536375, 0, 1152921504606846976, 75962, 258238559 1, 0, 11536375, 1, 1152921504606846977, 609189, 1515555074 2, 0, 11536375, 2, 1152921504606846978, 609189, 1530344731 " cat( ... -
Grid列包含int64值但过滤器显示字符串并且不起作用/(Grid column contains int64 values but filter shows strings and doesn't work/)[2022-12-27]
我们找到了解决方案,错误就在我们这边。 列创建等很好。 在某个地方,有人改变了价值类型。 We've found the solution and the mistake was on our side. Column creation etc is fine. Somewhere deep, someone has changed value types. -
一个更完整的例子: http : //play.golang.org/p/1RzDiw7F9t package main import ( "fmt" "math/rand" ) type Task interface { Do() error ID() int64 } type XTask struct { id int64 // other stuff } func NewXTask( /*task parameters...*/) *XTask ...