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
中