mvc.view.prifix/suffix
必須主動配置給出,另外必須導入JSP的默認渲染servlet:"org.apache.jasper.servlet.JspServlet"
,即添加依賴:<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
複製代碼
java -jar
來獨立運行"src/main/webapp/WEB-INF/web.xml"
error.jsp
錯誤頁面並不可以複寫默認的error handling view
,若是你想要自定義錯誤頁面,請嘗試其餘模板引擎Custom error pages src/main/webapp
目錄,儘管該目錄也是一個公共標準,可是它僅僅在war中有效,由於生成jar的構建工具將會自動把該目錄忽略Do not use the
src/main/webapp
directory if your application is packaged as ajar
. Although this directory is a common standard, it works only with war packaging, and it is silently ignored by most build tools if you generate a jar.html
歡迎頁
同時支持靜態資源
和模板引擎
,若是項目中不存在" "、"/"
的Handling
,那麼將優先查看靜態資源位置中是否存在index.html
,不然纔會查看index模板
,若是都不存在
將使用默認歡迎頁
Spring Boot supports both static and templated welcome pages. It first looks for an index.html file in the configured static content locations. If one is not found, it then looks for an index template. If either is found, it is automatically used as the welcome page of the application.java
Spring5.+
中與SpringMVC
擔負對等
做用的SpringWebFlux
並非徹底依賴於Servlet API
,因此不能將它打包成war
更不能使用src/main/webapp
目錄Spring
WebFlux
applications do not strictly depend on theServlet API
, so they cannot be deployed as war files and do not use thesrc/main/webapp
directory.web
src/main/webapp
中的靜態資源,但並不能直接訪問src/main/resources
中的靜態資源,可是Spring提供了ResourceHttpRequestHandler
來配置src/main/resources(classpath)
下指定訪問目錄Interceptor
只可以攔截Handling
與src/main/webapp
中的靜態資源,對src/main/resources
中的靜態資源無效src/main/webapp/WEB-INF
的直接訪問權限,可是能夠經過程序中forward
、redirect
達到間接
訪問的目的,因此war項目中一般會將須要控制權限的資源文件放入到WEB-INF
中