JSP规范让我可以服务.html
使用以下方法将文件作为 JSP(即让容器将它们作为 JSP 文件处理)<jsp-config>
部分在web.xml
, e.g.:
<web-app …>
<jsp-config>
<jsp-property-group>
<url-pattern>*.html</url-pattern>
</jsp-property-group>
</jsp-config>
</web-app>
但是当我切换到运行@SpringBootApplication
有了嵌入式Tomcat,它完全绕过了web.xml
文件。 Spring Boot MVC 中是否有等效的设置来按照标准设置 JSP 属性组的 JSP 配置web.xml
,这将配置existing嵌入式 Tomcat JSP servlet?
(我可能想要配置的 JSP 设置的另一个示例是<trim-directive-whitespaces>
.)
可能重复
我知道walkeros 的广泛回答 https://stackoverflow.com/a/32628600/421049,但该答案只考虑添加newJSP 小服务程序。它不涉及将新的 JSP 属性组添加到existingJSP servlet,确实没有提到<jsp-config>
部分在web.xml
at all.
更新的答案:
The spring-boot-starter-web
不依赖web.xml
,因此不能将两者结合使用。有一种使用方法web.xml
with Spring Boot
,所谓的“传统”做事方式,例如这个示例项目 https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-traditional。看来你只会使用spring-boot-starter
,以及 jsp/web 框架(示例项目中的 Spring MVC),并使用web.xml
用于 servlet 配置。
原始答案,有关spring-boot-starter-web
(没有为.html
-files):
要配置 Spring boot 如何查找视图文件,请使用以下属性application.properties
:
spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .html
要查看 Spring Boot 支持的所有属性,请参阅这个链接 https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html。跳到SPRING MVC
找到与此案例相关的内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)