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


你可能感兴趣的:(java后端,java后端所遇到的错误集锦)