一、遇到问题
punlic void go()
{
if(a) request.getRequestDispatcher(“/a.jsp”).forward(request, response);
if (b) request.getRequestDispatcher(“/b.jsp”).forward(request, response);
}
执行该方法会报Cannot forward after response has been committed
二、查找原因
这两次分发有可能同时执行,执行a分发是正常,但b分发就不能够正常再次转向了。
三、解决办法
punlic void go()
{
if(a)
{
request.getRequestDispatcher(“/a.jsp”).forward(request, response);
return;
}
if (b) request.getRequestDispatcher(“/b.jsp”).forward(request, response);
}