java.lang.IllegalStateException: Cannot (forward | sendRedirect | create session) after response has been committed

后端 未结 8 1069
南笙
南笙 2020-11-21 11:06

This method throws

java.lang.IllegalStateException: Cannot forward after response has been committed

and I am unable to spot th

8条回答
  •  执念已碎
    2020-11-21 11:35

    You should add return statement while you are forwarding or redirecting the flow.

    Example:

    if forwardind,

        request.getRequestDispatcher("/abs.jsp").forward(request, response);
        return;
    

    if redirecting,

        response.sendRedirect(roundTripURI);
        return;
    

提交回复
热议问题