Web 描述符中 web-app 中的版本属性是否影响实际使用的 Servlet API 版本?
Does the version attribute in web-app in the web descriptor affect the actual Servlet API version used?
网络上有许多提示表明 web.xml
、<web-app version="xxx">
中的版本必须与相应应用程序使用(和预期)的当前 API 相匹配。例如:
- Java web app - What determines my Servlet API version? Does it get specified in web.xml?
- What exactly is the web-app version? What does it affect?
- org.apache.jasper.JasperException: The function test must be used with a prefix when a default namespace is not specified
- How can I check what version of EL is server using
- webapp version 2.4 to 2.5 out of memory
但是我没能证明。 version
对编译 JSP 有影响吗?
背景
我一直在 Tomcat 6.0.45.
中调试 [...] JasperException: somewhere.jsp(69,10) The function concat must be used with a prefix when a default namespace is not specified
经过一些研究,我发现 somewhere.jsp
调用一个带参数的 bean 方法,仅在 EL 2.2+ 中支持(参见示例 Differences between EL 2.1 and 2.2)。到目前为止一切顺利:Tomcat 6.0.45 是一个仅支持 EL 2.1 的 servlet 2.5 容器。
但我随后在 Tomcat 8.0.32(Servlet 3.1,EL 3.0)上安装了相同的应用程序,并且使用相同的 web.xml
,但没有显示失败,这让我感到惊讶我,因为在 web.xml
中,我有 version="2.4"
.
我进一步尝试通过仅更改此 version
属性来调整用于编译的 Servlet API 版本和 运行 JSP 也失败了,所以我很困惑.
web.xml中指定的版本只决定了用于解析web.xml文件的规则。容器的行为始终由其实现的规范版本决定。
例如,您不能通过在 web.xml 中指定 version="2.5"
来禁用注释扫描(在 Servlet 3.0 / Tomcat 7 中引入)。有关此要求的示例,请参阅 Servlet 3.0 servlet 规范的第 1.6.2 节。
网络上有许多提示表明 web.xml
、<web-app version="xxx">
中的版本必须与相应应用程序使用(和预期)的当前 API 相匹配。例如:
- Java web app - What determines my Servlet API version? Does it get specified in web.xml?
- What exactly is the web-app version? What does it affect?
- org.apache.jasper.JasperException: The function test must be used with a prefix when a default namespace is not specified
- How can I check what version of EL is server using
- webapp version 2.4 to 2.5 out of memory
但是我没能证明。 version
对编译 JSP 有影响吗?
背景
我一直在 Tomcat 6.0.45.
中调试[...] JasperException: somewhere.jsp(69,10) The function concat must be used with a prefix when a default namespace is not specified
经过一些研究,我发现 somewhere.jsp
调用一个带参数的 bean 方法,仅在 EL 2.2+ 中支持(参见示例 Differences between EL 2.1 and 2.2)。到目前为止一切顺利:Tomcat 6.0.45 是一个仅支持 EL 2.1 的 servlet 2.5 容器。
但我随后在 Tomcat 8.0.32(Servlet 3.1,EL 3.0)上安装了相同的应用程序,并且使用相同的 web.xml
,但没有显示失败,这让我感到惊讶我,因为在 web.xml
中,我有 version="2.4"
.
我进一步尝试通过仅更改此 version
属性来调整用于编译的 Servlet API 版本和 运行 JSP 也失败了,所以我很困惑.
web.xml中指定的版本只决定了用于解析web.xml文件的规则。容器的行为始终由其实现的规范版本决定。
例如,您不能通过在 web.xml 中指定 version="2.5"
来禁用注释扫描(在 Servlet 3.0 / Tomcat 7 中引入)。有关此要求的示例,请参阅 Servlet 3.0 servlet 规范的第 1.6.2 节。