【问题标题】:Java project unknown enum in web.xmlweb.xml 中的 Java 项目未知枚举
【发布时间】:2016-04-17 07:58:16
【问题描述】:

我正在学习过滤器。所以我的 web.xml 中有以下代码:

    <filter>
    <filter-name>asyncFilter</filter-name>
    <filter-class>el.test.AnyRequestFilter</filter-class>
    <async-supported>true</async-supported>
</filter>

<filter-mapping>
    <filter-name>asyncFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>ASYNC</dispatcher>
</filter-mapping>

当我写是自动完成我ASYNC,但之后它变成红色,IntelliJ 告诉我错误是unknown enum。 这是为什么? 感谢您的关注。

附:我也有以下代码的问题:

<error-page>
    <location>/WEB-INF/jsp/view/badRequest.jsp</location>
    <error-code>404</error-code>
</error-page>

&lt;error-code&gt; 上写的是no child element expected at this point,但代码正在运行(我可以运行它)。

【问题讨论】:

    标签: web.xml servlet-filters


    【解决方案1】:

    来自https://docs.oracle.com/cd/E19879-01/819-3669/bnagf/index.html

    4.In the Add Filter Mapping dialog, select one of the following dispatcher types:
    
    REQUEST: Only when the request comes directly from the client
    FORWARD: Only when the request has been forwarded to a component (see Transferring Control to Another Web Component)
    INCLUDE: Only when the request is being processed by a component that has been included (see Including Other Resources in the Response)
    ERROR: Only when the request is being processed with the error page mechanism (see Handling Servlet Errors)
    

    所以 ASYNC 不是有效值。

    编辑:它似乎是在 javaee 6 中添加的:http://docs.oracle.com/javaee/6/tutorial/doc/bnagb.html

    所以你的项目和 IDE 可能存在 JRE/JDK 版本的配置问题。

    【讨论】:

    • 其实编译运行正常,但奇怪的是IDE显示为错误。我尝试重建,重新启动并没有效果。
    • 我假设您使用 java 1.6+ 中配置的 maven 等集成工具进行编译并运行它。但是您的 ide 是否使用 JDK/JRE 1.6+ 运行?它是否配置了适当的设置,即java版本,某些方面的版本?
    • 我从设置中配置 JDK/JRE。但还有一些东西——JavaEE 版本等等,我不碰它们。应该在某个地方添加一些 JavaEE 文件的路径(比如标准 jdk 的路径)?我是 JavaEE 的新手,我不明白幕后到底发生了什么。感谢您的关注。
    • 那我该如何配置EE版本?
    • 说实话我很难说。检查您的全局配置(工作区)。检查你的项目的属性,你的项目属性中可能有一个 Facets 部分,如果有的话,也要检查那里。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 2012-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    相关资源
    最近更新 更多