Programmatic Servlet 3.0 JSP jsp属性组配置

问题描述 投票:4回答:1

我能够在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>
java java-ee servlet-3.0
1个回答
0
投票

我发现无法完成,Servlet 3.x仅指定JSP设置的读取接口。

要编写JSP设置,需要访问JSP引擎实现,或者继续使用web.xml。后者不是大问题,因为web.xml可以安全地与ServletContainerInitializer共存。因此,建议保留web.xml

但是,这是Spring Boot的问题,它忽略了web.xml

使用Spring Boot 2]和嵌入式Tomcat,可以使用TomcatContextCustomizer:]实现>

TomcatContextCustomizer

© www.soinside.com 2019 - 2024. All rights reserved.