xsd java引用_web.xml文件的 xsd引用(或dtd引用)学习
1. 為什么web.xml會有不同版本的xsd引用:
JDK依賴變化;
或 servlet(JAVA EE)自身API的改變;
2. 為什么會有dtd和xsd兩個版本的區別
我是在這篇文章中看到的,作者似乎拷貝了一段API說明:
There are two ways to specify the schema for a the web.xml file (Deployment Descriptor).
DTD - Document Type Definition
XSD - XML Schema Definition
The XSD version is preferred since JSP 2.0 / Servlets 2.4 (eg: Tomcat 5.5). Note that the XML encoding can be specified as ISO-8859-1, UTF-8, or any other valid encoding in either version, and should match the actual encoding of your text file.
XSD example for JSP 2.1 / Servlets 2.5 (Tomcat 6.0):
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_5.xsd"
version="2.5">
XSD example for JSP 2.0 / Servlets 2.4 (Tomcat 5.5):
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"
version="2.4">
DTD example for JSP 1.2 / Servlets 2.3 (Tomcat 5):
/p>
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
在這里,也就說了,DTD是早期支持的方式,后期盡量用XSD。為什么XSD成為趨勢,這里有個很好的注解《如何使用XSD》《XML中DTD,XSD的區別與應用》。
DTD和XSD相比:DTD 是使用非 XML 語法編寫的。
DTD 不可擴展,不支持命名空間,只提供非常有限的數據類型 .
3. web.xml幾個版本的列表
web.xml v2.3
web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd">
web.xml v2.4
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">
web.xml v2.5
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.xml v3.0
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">
總結
以上是生活随笔為你收集整理的xsd java引用_web.xml文件的 xsd引用(或dtd引用)学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java jdbc脚本_关于java:使
- 下一篇: linux java转码_用Linux