spring boot 2.x Path with "WEB-INF" or "META-INF"

學習spring boot 2.x時,使用jsp做爲前端頁面。在application.properties配置了jsp所在位置前端

spring.mvc.view.prefix:/WEB-INF/views/
spring.mvc.view.suffix:.jspjava

啓動spring boot時報錯,找不到頁面spring

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.apache

Sun Mar 10 21:37:47 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available
 
服務器端日誌輸出爲:
o.s.w.s.r.ResourceHttpRequestHandler     : Path with "WEB-INF" or "META-INF": [WEB-INF/views/home.jsp]
 
緣由是spring boot默認不使用jsp,須要在pom中引用jsp的編譯程序:


<!--jsp頁面使用jstl標籤 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>tomcat

<!--用於編譯jsp -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>服務器

相關文章
相關標籤/搜索