《Springboot極簡教程》問題解決:Springboot啟動(dòng)報(bào)錯(cuò) Whitelabel Error Page: This application has no explicit mapping for

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Mar 28 22:25:43 CST 2017
There 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.)

首先,這個(gè)出錯(cuò)頁面是SpringBoot的一個(gè)默認(rèn)出錯(cuò)頁面。源碼在:org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration 第151行。
這種錯(cuò)誤一般是配置錯(cuò)誤,或者M(jìn)VC報(bào)錯(cuò)引起的錯(cuò)誤。
比如說,在newer versions of Spring, following needs to be put in application.properties file:

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

Also, JSP files need to be put under src/main/resources/META-INF/resources/WEB-INF/jsp

推薦直接使用java代碼配置的方式,這樣方便看代碼:

package com.restfiddle.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by jack on 2017/3/28.
 *
 * @author jack
 * @date 2017/03/28
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        //spring.view.prefix=/WEB-INF/jsp/
        //spring.view.suffix=.jsp
        registry.jsp("/WEB-INF/jsp/", ".jsp");
        //registry.freeMarker();
        //registry.velocity();
        //registry.groovy();
    }

}

問題參考:

http://stackoverflow.com/questions/27113452/circular-view-path-in-a-simple-spring-boot-project-with-a-controller

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容