您的位置:首页 > 编程语言 > Java开发

springboot启动报错:whitelabel error page

2018-01-29 20:03 666 查看
错误描述:

Whitelabel Error PageThis application has no
explicit
mapping for
/error, so you are seeing this
as a fallback.Tue Mar 28
22:25:43
CST 2017There
was an unexpected error (type=Internal Server Error, 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.)

在测试过程中我用bean尝试过注入:

import org.springframework.context.annotation.Bean;

import org.springframework.web.servlet.ViewResolver;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import org.springframework.web.servlet.view.InternalResourceViewResolver;

public class WebConfig  extends WebMvcConfigurerAdapter{
//配置jsp视图解析器
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver resolver=new InternalResourceViewResolver();
resolver.setPrefix("/views/");
resolver.setSuffix(".jsp");
resolver.setExposeContextBeansAsAttributes(true);
return resolver;
}
这两个地方,在springboot的区别中,早期的版本中是不带mvc的,在1.0的配置中是需要带mvc的(特殊错误,需要特别记忆)
#spring.view.prefix=/views/
#spring.view.suffix=.jsp
#spring.mvc.view.prefix=/views/
#spring.mvc.view.suffix=.jsp

}

解决方案:在application.properties文件中正确配置模板文件的命名前后缀:

#spring.mvc.view.prefix=/views/
#spring.mvc.view.suffix=.jsp

另外,在早期版本的springboot中,这个key中是不带mvc的:

  #spring.view.prefix=/views/
#spring.view.suffix=.jsp

这个配置类是1.1版本之后的,在org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties类中。上面的注解@ConfigurationProperties(prefix
= "spring.mvc")指明了这个key
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: