【发布时间】:2017-10-15 09:10:14
【问题描述】:
我尝试在我的 Spring Boot 应用程序中转到登录页面,但出现此错误
Circular view path [/login.jsp]: would dispatch back to the current handler URL [/login.jsp] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
在stackoverflow上人们给出需要添加百里香依赖的建议
('org.springframework.boot:spring-boot-starter-thymeleaf')
但在那之后我得到了这个错误
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template "login", template might not exist or might not be accessible by any of the configured Template Resolvers
这个错误表明Spring在/resurses/templates文件夹中找不到模板login.html。
如果我在另一个文件夹中有自己的 login.jsp 并且我不想使用任何模板,我该怎么办?
这是我的登录映射
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(Model model, String error, String logout) {
if (error != null)
model.addAttribute("error", "Your username and password is invalid.");
if (logout != null)
model.addAttribute("message", "You have been logged out successfully.");
return "login";
}
这是我的安全配置
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/resources/**", "/registration").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
【问题讨论】:
-
您是如何定义对 .html 文件的路径引用的??
-
@Afridi 我的项目中没有任何 .html 文件我只有 .jsp 文件
标签: java spring spring-mvc spring-boot