1.jsp页面
<body>
<iframe frameborder="0" src="include/top.html" width="100%" height="189px" scrolling="no" name="iframetop"></iframe>
<iframe frameborder="0" src="index.action?method=index" width="100%" height="1320px" scrolling="no" name="iframecenter" ></iframe>
<iframe frameborder="0" src="include/bottom.html" width="100%" height="120px" scrolling="no" name="iframecenter" ></iframe>
</body>
2.servlet跳转
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
String method = req.getParameter("method");
if(method != null){
System.out.println(method);
this.index(req, resp);
}else{

}
}
protected void index(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
super.service(req, resp);
List tzxxlist = tzxxservice.findAll();
req.setAttribute("tzxxlist", tzxxlist);
req.getRequestDispatcher("include/center.jsp").forward(req, resp);
return;
}3.报错
HTTP Status 500 - Cannot forward after response has been committed--------------------------------------------------------------------------------type Exception reportmessage Cannot forward after response has been committeddescription The server encountered an internal error that prevented it from fulfilling this request.exception java.lang.IllegalStateException: Cannot forward after response has been committed
com.jztjs.www.servlet.IndexServlet.index(IndexServlet.java:77)
com.jztjs.www.servlet.IndexServlet.service(IndexServlet.java:47)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.33 logs.
servletapacheserver

解决方案 »

  1.   

    用绝对路径试试,再有BUG跑一下,看看这个代码有没有重复跑
      

  2.   

    不需要调用super.service(req, resp);
      

  3.   

    java.lang.IllegalStateException: Cannot forward after response has been committed
    看看代码吧,这个就是发生了多次跳转
      

  4.   

    protected void service(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    req.setCharacterEncoding("UTF-8");
    resp.setCharacterEncoding("UTF-8");
    String method = req.getParameter("method");
    if(method != null){
    System.out.println(method);
    this.index(req, resp);
    return;
    }else{}
    }
    protected void index(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
    super.service(req, resp);
    List tzxxlist = tzxxservice.findAll();
    req.setAttribute("tzxxlist", tzxxlist);
    req.getRequestDispatcher("include/center.jsp").forward(req, resp);
    return;
    }这样试试吧
      

  5.   

    http://blog.csdn.net/fenglibing/article/details/4106564看看这个