zoukankan      html  css  js  c++  java
  • (转)使用Servlet3.0新特性asyncSupported=true时抛异常java.lang.IllegalStateException: Not support...

    http://www.tuicool.com/articles/zYfmme

    最近在运用Servlet3.0新特性:异步处理功能的时候出现以下了2个问题:

    运行时会抛出以下两种异常:

    一月 19, 2014 3:07:07 下午 org.apache.catalina.core.StandardWrapperValve invoke
    严重: Servlet.service() for servlet [servletTest.AsyncServlet] in context with path [/idea] threw exception
    java.lang.IllegalStateException: Not supported.
    一月 19, 2014 2:42:01 下午 org.apache.catalina.core.ApplicationContext log

    经过反复排查,终于查出了问题原因,不多说,直接上结论:

    1.使用asyncSupported=true必须运用tomcat7+JDK6以上版本。

    2.必须在一个请求涉及的所有Servlet及Filter中都声明asyncSupported=true。

    简单地说:

    我写了一个AsyncServlet.java(extends HttpServlet)中声明了asyncSupported=true,

    但是该请求还同时会触发另外3个Filter,所以这3个Filter中也 必须声明asyncSupported=true ,

    这就是这个使用asyncSupported这个属性的关键。

    ============================================================

    http://www.cnblogs.com/yangzhilong/p/3725128.html

    在spring mvc3.2及以上版本增加了对请求的异步处理,是在servlet3的基础上进行封装的。

    1、修改web.xml

    复制代码
    <?xml version="1.0" encoding="UTF-8"?>
    <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">
    ...
    </web-app>
    复制代码

    1.1、声明version="3.0",声明web-app_3_0.xsd

    1.2、为servlet或者filter设置启用异步支持:<async-supported>true</async-supported>,修改WEB应用的web.xml

    复制代码
    <!-- spring mvc -->
    <servlet>
    <servlet-name>SpringMvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>...</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <async-supported>true</async-supported>
    </servlet>
    复制代码
  • 相关阅读:
    允许debian wheezy支持IOS7+的iphone.
    openSUSE 国内镜像摘要
    策略模式总结
    顺序串
    WindowState注意事项
    NLP | 自然语言处理
    Using Autorelease Pool Blocks
    NSAutoreleasePool & thread
    oc语言特性
    oc语言基础整理
  • 原文地址:https://www.cnblogs.com/xingxing0521/p/5306824.html
Copyright © 2011-2022 走看看