web.xml中的<async-supported> true </ async-supported>

par*_*ent 4 web.xml jersey

有人帮助我plss,当我在web.xml中放入async支持的标记时出现此错误:

cvc-complex-type.2.4.a:从元素'async-supported'开始发现无效内容.其中一个"{' http://java.sun.com/xml/ns/javaee ':运行为,’ http://java.sun.com/xml/ns/javaee ’:安全角色引用} ' 是期待.

这是我的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>
Run Code Online (Sandbox Code Playgroud)

Pau*_*tha 12

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 -->
Run Code Online (Sandbox Code Playgroud)