springboot启动报错:whitelabel error page

错误描述:

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值