[英]What does a Servlet 3.0 compatible web-app declaration in web.xml do?
I am deploying a web application that is declared in web.xml and deployed as a .war file. 我正在部署一个在web.xml中声明并部署为.war文件的Web应用程序。
I am deploying on Jetty 9.1.x (but I think this question is not container specific). 我正在Jetty 9.1.x上部署(但我认为这个问题不是特定于容器的)。
My web.xml file is quite old and declares itself as a Servlet 2.4 application: 我的web.xml文件很旧,并声明自己是一个Servlet 2.4应用程序:
<web-app version="2.4" id="my_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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
My configuration actually declares some Servlet 3.0 only features, like a default error page. 我的配置实际上声明了一些仅Servlet 3.0的功能,比如默认的错误页面。 These features do not validate according to the schema, but the features seem to work correctly.
这些功能不会根据架构进行验证,但功能似乎可以正常工作。
Since I am using 3.0 features, I would like to change the declaration to be correct: 由于我使用3.0功能,我想将声明更改为正确:
<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_3_0.xsd"
version="3.0">
But I am scared to do this because I don't understand what the difference will be to Jetty. 但我害怕这样做,因为我不明白Jetty的区别。
Will changing the declaration have any effect on the runtime behavior of Jetty? 更改声明是否会影响Jetty的运行时行为? Does Jetty treat a 2.4 app somehow differently than a 3.0 app?
Jetty对待2.4应用程序的方式与3.0应用程序不同吗?
You should be able to simply swap the schema declaration from 2.4 to 3.0 . 您应该能够简单地将架构声明从2.4交换到3.0 。
Initially I set off to prove it by doing diff
between 2.4 and 2.5 and another one comparing 2.5 and 3.0 . 最初我开始通过在2.4和2.5之间进行
diff
来证明它,并且另一个比较2.5和3.0 。
I have convinced myself that the differences between 2.4 and 2.5 are only additive and the name space have shifted from j2ee
to javaee
. 我已经说服自己, 2.4和2.5之间的差异只是附加的,名称空间已从
j2ee
转移到javaee
。
However xsd schema for 3.0 is smaller then 1/3rd of the other two versions. 但是 , 3.0的 xsd架构比其他两个版本的1/3小。 Not sure how to proceed in this case (any ideas welcome!)
在这种情况下不确定如何处理(欢迎任何想法!)
You can download all schemas from here and do the comparison yourself: 您可以从此处下载所有模式并自行进行比较:
Here are the what's new articles describing each new version of the standard: 以下是描述该标准的每个新版本的新文章:
If you read in, the changes to web.xml
descriptor mentioned in the articles are minute. 如果您读入, 文章中提到的对
web.xml
描述符的更改是微小的。
What I would do is simply list all the elements in your original web.xml
and confirm that they do exist in this document describing the 3.0 schema . 我要做的只是列出原始
web.xml
中的所有元素,并确认它们确实存在于描述3.0模式的本文档中。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.