我能够在ServletContainerInitializer中创建servlet和过滤器,但是是否有可能将旧web.xml
的最后剩余部分转换为Servlet 3.0程序化配置?
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
<trim-directive-whitespaces>true</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
我发现无法完成,Servlet 3.x仅指定JSP设置的读取接口。
要编写JSP设置,需要访问JSP引擎实现,或者继续使用web.xml
。后者不是大问题,因为web.xml
可以安全地与ServletContainerInitializer
共存。因此,建议保留web.xml
。
但是,这是Spring Boot的问题,它忽略了web.xml
。
使用Spring Boot 2]和嵌入式Tomcat,可以使用TomcatContextCustomizer
:]实现>TomcatContextCustomizer