com.alibaba.fastjson.JSONException: toJSON error
com.alibaba.fastjson.JSON.toJSON(JSON.java:987)
com.alibaba.fastjson.JSON.toJSON(JSON.java:888)
。。。。。。
root cause
java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
org.apache.catalina.connector.Request.getAsyncContext(Request.java:1695)
org.apache.catalina.connector.RequestFacade.getAsyncContext(RequestFacade.java:1055)
我写的代码如下:
public class TestFilter implements Filter {
static final Logger logger = LoggerFactory.getLogger(TestFilter.class);
public void init(FilterConfig filterConfig) throws ServletException {
}
//新建一个装饰者模式的request对象,以便对request对象的参数进行更改/过滤
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
logger.info("请求为:{}",JSON.toJSON(request));
chain.doFilter(request, response);//对request和response进行过滤
}
public void destroy() {
}
}