<async-supported>真</async-supported> web.xml
<async-supported>true</async-supported> in web.xml
请有人帮助我,我在 web.xml:
中放入支持异步的标签时出现此错误
cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref}' is expected.
这是我的web.xml
<web-app version="2.5" 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">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.yeditepeim.messenger.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
web.xml 采用 XML 架构。如果您不熟悉 XML 模式,它们描述了 XML 文档可以包含哪些元素和属性才能成为该模式的有效 实例 。
也就是说,您可以在模式位置中看到正在使用的模式文件的版本,即 ...web-app_2_5.xsd
。这意味着您的 web.xml 将基于该版本的架构,该版本映射到该版本的 servlet 规范,在您的情况下为 2.5
。这个问题是直到 3.0 才将异步引入到 servlet 规范中。所以 2.5 模式中没有元素规范。因此,当验证 xml 时,表示文档中不允许使用此类元素 <async-supported>
,因为它不符合架构。
要修复它,只需将版本更改为 3.0 并将架构文件更改为 3_0
<!-- change to 3.0 -->
<web-app version="3.0"
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">
<!-- change to 3_0 -->
请有人帮助我,我在 web.xml:
中放入支持异步的标签时出现此错误cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref}' is expected.
这是我的web.xml
<web-app version="2.5" 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">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.yeditepeim.messenger.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
web.xml 采用 XML 架构。如果您不熟悉 XML 模式,它们描述了 XML 文档可以包含哪些元素和属性才能成为该模式的有效 实例 。
也就是说,您可以在模式位置中看到正在使用的模式文件的版本,即 ...web-app_2_5.xsd
。这意味着您的 web.xml 将基于该版本的架构,该版本映射到该版本的 servlet 规范,在您的情况下为 2.5
。这个问题是直到 3.0 才将异步引入到 servlet 规范中。所以 2.5 模式中没有元素规范。因此,当验证 xml 时,表示文档中不允许使用此类元素 <async-supported>
,因为它不符合架构。
要修复它,只需将版本更改为 3.0 并将架构文件更改为 3_0
<!-- change to 3.0 -->
<web-app version="3.0"
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">
<!-- change to 3_0 -->