Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 异步servlet或筛选器不';行不通_Java_Servlets_Asynchronous - Fatal编程技术网

Java 异步servlet或筛选器不';行不通

Java 异步servlet或筛选器不';行不通,java,servlets,asynchronous,Java,Servlets,Asynchronous,我是JavaEE新手,即将学习使用异步servlet。我用一个简单的index.jsp创建了一个web应用程序,按下按钮后从中调用servlet。我总是会遇到以下例外情况: java.lang.IllegalStateException:请求在 不支持异步操作的筛选器或servlet 但我将async supported设置为true,作为servlet或web.xml中的注释,或以两种方式设置。我在这里搜索了几个小时类似的问题,但我找不到解决办法。我正在使用NetBeans 8.0.2和随Ne

我是JavaEE新手,即将学习使用异步servlet。我用一个简单的index.jsp创建了一个web应用程序,按下按钮后从中调用servlet。我总是会遇到以下例外情况:

java.lang.IllegalStateException:请求在 不支持异步操作的筛选器或servlet

但我将async supported设置为true,作为servlet或web.xml中的注释,或以两种方式设置。我在这里搜索了几个小时类似的问题,但我找不到解决办法。我正在使用NetBeans 8.0.2和随NetBeans一起提供的glassfish服务器4.1。这是我的index.jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Async Test</h1>
        <form method="get" action="Asynctest">
            <input type="submit"
                   value="Start test">
        </form>
    </body>
</html>
以及web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>Asynctest</servlet-name>
        <servlet-class>Controller.Asynctest</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>Asynctest</servlet-name>
        <url-pattern>/Asynctest</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

异步测试
控制器异步测试
真的
异步测试
/异步测试
30
这让我发疯。。谢谢你的帮助

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>Asynctest</servlet-name>
        <servlet-class>Controller.Asynctest</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>Asynctest</servlet-name>
        <url-pattern>/Asynctest</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>