作为标题,带"javaee:“前缀的标签和不带"javaee:”的标签有什么区别?
我发现我们需要使用不带"javaee:“的标签来设置配置,带有前缀"javaee:”的标签不起作用
例如:
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
</welcome-file-list>作品
但
<javaee:welcome-file-list>
<javaee:welcome-file>default.jsp</javaee:welcome-file>
<javaee:welcome-file>default.html</javaee:welcome-file>
</javaee:welcome-file-list>不起作用。
我使用tomcat 8.5.6作为服务器。
下面是我的web.xml:
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xml="http://www.w3.org/XML/1998/namespace" 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 ">
<display-name>SQUEEN WECHAT</display-name>
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/config/spring/applicationContext.xml
</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>WEB-INF/config/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>发布于 2016-11-10 18:14:34
有关xml名称空间,请阅读以下内容。它是xml的基础。

因此,在您的web.xml中,如果声明如下:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 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">您可以在不使用命名空间的情况下编写以下代码。
<welcome-file-list>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
</welcome-file-list>如果您的web.xml如下所示,那么它将具有一个自定义名称空间声明
(注: xmlns:javaee):
<web-app xmlns:javaee="http://java.sun.com/xml/ns/j2ee" 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">您必须将相同的名称空间写成如下所示:
<javaee:welcome-file-list>
<javaee:welcome-file>default.jsp</javaee:welcome-file>
<javaee:welcome-file>default.html</javaee:welcome-file>
</javaee:welcome-file-list>这就是xml的工作方式。没别的了。
https://stackoverflow.com/questions/40522761
复制相似问题