< async-supported> true</async-supported>在web.xml中 [英] <async-supported>true</async-supported> in web.xml

查看:106
本文介绍了< async-supported> true</async-supported>在web.xml中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人帮助我,当我在web.xml中放入异步支持的标签时,出现了此错误:

Someone help me plss, i got this error when i put async-supported tag in web.xml:

cvc-complex-type.2.4.a:发现无效的内容(从元素异步支持"开始). "{" http://java.sun.com/xml/ns/javaee":运行方式," http://java.sun.com/xml/ns/javaee :security-role-ref}'.

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

this is my 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文档可以包含哪些元素和属性,以便成为该模式的有效 instance .

The web.xml goes of an XML schema. If you're not familiar with XML schemas, they describe what elements and attributes an XML document can contain in order to be a valid instance of that schema.

话虽如此,您可以在模式位置中看到正在使用的模式文件的版本,即...web-app_2_5.xsd.这意味着您的web.xml将基于该模式的版本,该版本映射到该servlet规范的版本,在您的情况下为2.5.问题在于,直到3.0才将异步引入到servlet规范中.因此,在2.5模式中没有元素规范.因此,当验证xml时,就是说文档中不允许这样的元素<async-supported>,因为它不符合架构.

That being said, you can see in the schema location the version of the schema file being used, i.e. ...web-app_2_5.xsd. This means that your web.xml is going to be based on that version of the schema, which maps to that version of the servlet specification, which in your case is 2.5. The problem with this is that async is not introduced to the servlet spec until 3.0. So there is no element specification in the 2.5 schema. So when the xml is being validated, it's saying that not such element <async-supported> is allowed in the document, as it doesn't comply to the schema.

要修复此问题,只需将版本更改为3.0,将架构文件更改为3_0

To fix it, just change the version to 3.0 and the schema file to 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 -->

这篇关于&lt; async-supported&gt; true&lt;/async-supported&gt;在web.xml中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆