这种错误的通常原因是什么:
com.mycompany.myapp.servlet.TxnDetailsServlet doRequest
ERROR: View failed
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:312)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.mycompany.myapp.servlet.TxnDetailsServlet.doRequest(TxnDetailsServlet.java:82)
at com.mycompany.myapp.servlet.TxnDetailsServlet.doGet(TxnDetailsServlet.java:131)
servlet 处理请求(即设置属性)然后调用:
private void doRequest(HttpServletRequest request) throws IOException, ServletException {
// Code omitted
getServletContext().getRequestDispatcher("/Some.jsp").forward(this.request, this.response);
// Code omitted
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doGet(request, response);
doRequest(request);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
super.doPost(request, response);
doRequest(request);
}
servlet 不做任何响应。