Async support must be enabled on a servlet and for all filters involved in async request processing(
Posted huangjinyong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Async support must be enabled on a servlet and for all filters involved in async request processing(相关的知识,希望对你有一定的参考价值。
一、报错日志
java.lang.IllegalStateException: Async support must be enabled on a servlet and for all filters involved in async request processing. This is done in Java code using the Servlet API or by adding "<async-supported>true</async-supported>" to servlet and filter declarations in web.xml.
二、解决办法
1、修改web.xml头部信息,是因为<async-supported>true</async-supported>是web.xml 3.0的新特性,所以更改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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
2、添加<async-supported>true</async-supported>
在web.xml中对DispatcherServlet和所有filter添加 :<async-supported>true</async-supported>
3、如果集成了shiro一定要注意在mapping中增加dispatcher项,否则会抛org.apache.shiro.UnavailableSecurityManagerException异常
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
4、测试代码
@RequestMapping("callable") @ResponseBody public Callable<String> callable() { Callable<String> callable = new Callable<String>() { public String call() throws Exception { System.out.println("异步开始:" + System.currentTimeMillis()); Thread.sleep(5000); System.out.println("异步结束:" + System.currentTimeMillis()); return System.currentTimeMillis() +""; } }; System.out.println("主线程开始:" + System.currentTimeMillis()); return callable; }
以上是关于Async support must be enabled on a servlet and for all filters involved in async request processing(的主要内容,如果未能解决你的问题,请参考以下文章
ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=(代
“Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets
Discord.js MongooseError: Callback must be a function, got [object Object]
Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be ena
Error running app: Instant Run requires 'Tools | Android | Enable ADB integration' to be ena
colMedians(x) : Argument ‘x’ must be a matrixrowMedians(data) : Argument ‘x‘ must be a matrix.