检查异步 servlet 的行为更改

在 Servlet 3.0 规范中,如果请求中包含查询字符串,那么会向被分派资源提供此字符串。在 Servlet 3.1 规范中,如果向分派资源提供了某个查询字符串,那么会向被分派资源提供此查询字符串,而不会提供来自原始请求的查询字符串。

以下示例说明了这一行为差异:


Request for /FirstResource?param=One

First Resource:

getParameter("param"); // returns "One"

Forward request to /SecondResource?param=Two

SecondResource:

getParameter("param"); // returns "Two"
AsyncContext ac = getAsyncContext();
ac.start();
ac.dispatch(); // dispatches to /FirstResource

First Resource:

Servlet-3.0 feature : getParameter("param") returns "One"
Servlet-3.1 feature : getParameter("param") returns "Two"

不允许调用 AsyncContext.dispatch()AsyncContext.complete() 方法且生成以下异常后获取请求或响应对象:

java.lang.IllegalStateException: SRVE9015E: 无法在 AsyncContext.dispatch() 或 AsyncContext.complete() 后获取请求或响应对象。

此规则将标记以下各项:

有关 Servlet 3.1 行为更改的更多信息,请参阅以下资源:Servlet 3.1 behavior changes