我可以将 Apache Tomcat 7 与 servlet api 2.5 一起使用吗 [英] Can I use Apache Tomcat 7 with servlet api 2.5
问题描述
tomcat 6 存在漏洞,所以我升级到使用 servlet api 3.0 的 tomcat 7.082.
There is a leak with tomcat 6, so I am upgrading to tomcat 7.082 which uses servlet api 3.0.
我已将使用 servlet 2.5 的 war 文件部署到 Apache tomcat 7.0.82.应用运行良好,我没有看到任何直接问题.
I have deployed the war file which uses servlet 2.5 to Apache tomcat 7.0.82. the app is running is fine and i do not see any immediate issues.
所以我的问题是,这样做可以吗?我最终会在生产环境中推出这项更改...
so my question is, is it OK to do this? I will eventually be rolling out this change to production...
推荐答案
Tomcat 7 可以很好地运行 Servlet 2.5 应用程序.最重要的是确保您的 web.xml 指定版本.因此,对于您的示例,它看起来像:
Tomcat 7 will run a Servlet 2.5 application just fine. The biggest thing is to make sure your web.xml specifies the version. So, for your example, it would look something like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
...
</web-app>
这告诉容器(在本例中为 Tomcat)此 Web 应用程序遵循 Servlet 2.5 规范.
This tells the container (Tomcat in this case) that this web application follows the Servlet 2.5 spec.
这篇关于我可以将 Apache Tomcat 7 与 servlet api 2.5 一起使用吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!