Eclipse在我的web.xml中报告问题,但它处理得很好

san*_*ity 2 java eclipse google-app-engine servlets

我正在使用Google App Engine和Eclipse中的Google插件,这是我的web.xml的标题:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
Run Code Online (Sandbox Code Playgroud)

基于一些GAE文档,我添加了这个:

<security-constraint>
    <web-resource-collection>
        <url-pattern>/tasks/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

但是,Eclipse在"url-pattern"上报告错误:

cvc-complex-type.2.4.a:从元素'url-pattern'开始发现无效内容.
其中一个"{"http://java.sun.com/xml/ns/javaee":web-resource-name}"的预期.

我可以启动应用程序,它似乎处理web.xml文件就好了,但我不喜欢Eclipse报告错误的事实.问题是什么?

pes*_*ira 8

好吧,这个错误看起来非常简单 - 它在url-pattern之前预期的web-resource-name标签:)

干杯


Jun*_*per 7

只是添加确切的代码

<security-constraint>
    <web-resource-collection>
        <web-resource-name>tasks</web-resource-name>
        <url-pattern>/tasks/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)