记录一个Tomcat启动参数修改,导致不识别的问题

web3.0之后新增一个的属性,支持web.xml中filter添加 标签。

标准情况下只要Tomcat7.0+  JDK1.6+就可以支持该功能,然后这次遇到Tomcat启动报无法识别该属性的问题,花费了很长时间定位,这里记录一下原因。


tomcat启动参数中添加的一个参数 : JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=true"

就是该参数最终导致了Tomcat无法识别标签,war包启动失败。


在Tomcat官方文档中查询了一下(https://tomcat.apache.org/tomcat-8.5-doc/config/context.html),该参数的解释如下:

The default value of this system property is false.
If this is true the default values will be changed for:
org.apache.catalina.core.
ApplicationContext.GET_RESOURCE_REQUIRE_SLASH
org.apache.catalina.core.
ApplicationDispatcher.WRAP_SAME_OBJECT
org.apache.catalina.core.
StandardHostValve.ACCESS_SESSION
org.apache.catalina.session.
StandardSession.ACTIVITY_CHECK
org.apache.catalina.session.
StandardSession.LAST_ACCESS_AT_START
org.apache.tomcat.util.http.
ServerCookie.STRICT_NAMING
The URIEncoding attribute of any HTTP connector or AJP connector element.
The resourceOnlyServlets attribute of any Context element.
The tldValidation attribute of any Context element.
The useRelativeRedirects attribute of any Context element.
The xmlNamespaceAware attribute of any Context element.
The xmlValidation attribute of any Context element.

在查看具体的解释分析,应该是 resourceOnlyServlets 属性造成了这个问题:
Comma separated list of Servlet names (as used in /WEB-INF/web.xml) that expect a resource to be present. Ensures that welcome files associated with Servlets that expect a resource to be present (such as the JSP Servlet) are not used when there is no resource present. This prevents issues caused by the clarification of welcome file mapping in section 10.10 of the Servlet 3.0 specification. 

先粗略记录一下,有时间再研究

你可能感兴趣的:(tomcat)