你是这样用吗?
<jsp:forward page="load.jsp?url=manage_dpt.jsp"/>
Welcome to 闪龙:[flash反编专家]
http://www.flashlong.com
http://www.flashlong.com/bbs

解决方案 »

  1.   

    在forward之前已经把页面提交了吧?比如在form里面有action的指向。
      

  2.   

    我是用的struts tiles结构,body部分定义的jsp文件中使用该语句,这样不能转向吗?该怎样用?
      

  3.   

    <%@ page language="java"%>
    <%@ page contentType="text/html;charset=gb2312"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="java.util.*"%>
    <!--%@ page import="DbAccess.*"%--><jsp:useBean id="connBean" scope="page" class="cn.edu.shu.cims.printing.common.DBConnBean"/>
    <jsp:useBean id="queryBean" scope="page" class="cn.edu.shu.cims.printing.common.DatabaseQuery"/><%
    String querySQL = "select * from EMP";
    String nextPage;
    Connection conn=null;
    conn=connBean.getConnect();
    if(conn == null)
    {
    //nextPage="../../errors/DbConnError.jsp";
    nextPage="../../index.jsp";
    out.println("conn is error");
    %>
       <jsp:forward page="<%= nextPage %>" />
    <%
    }
    %>
    <%
      queryBean.init(conn, request, 10, querySQL);
    %>
    后面是关于不为空的处理
      

  4.   

    是不是由out.println语句引起的?你把该句注释掉。
    我这边帮你调试一下
      

  5.   

    去掉也不行,我想是否是因为采用了Struts tiles结构,以上文件本身是在body这个变量定义的,然后又从该文件转向,出现了问题?
      

  6.   

    不过你可以不用jsp:forward来跳转页面,可以用这条语句:
    if(conn == null)
    {
    //nextPage="../../errors/DbConnError.jsp";
    nextPage="../../index.jsp";
    //out.println("conn is error");
             response.sendRedirect(nextPage);
             return;
    }这样也把<%%>省了,注意:return语句一定要加,不然程序会继续执行的。
      

  7.   

    不过你可以不用jsp:forward来跳转页面,可以用这条语句:
    if(conn == null)
    {
    //nextPage="../../errors/DbConnError.jsp";
    nextPage="../../index.jsp";
    //out.println("conn is error");
             response.sendRedirect(nextPage);
             return;
    }这样也把<%%>省了,注意:return语句一定要加,不然程序会继续执行的。
      

  8.   

    因为该文件本身是一个完整网页的一部分。不知道讲清楚了没有。你应该了解struts这种结构吧。无论如何,非常感谢你。
      

  9.   

    在用forward的前面不能有out语句。
      

  10.   

    如果采用struts结构,应尽量少在JSP页面中使用页面跳转语句,最理想的情况是所有的页面流转均应在Controller中进行,而Controller一般都是用servlet实现的。
      

  11.   

    是这样,但是因为不是在form表单中提交,所以不知怎样用action实现这种转向。用response.sendRedirect(nextPage);
             return;
    语句,body部分为空,不转向也不报错了。
      

  12.   

    我这些跳转语句还好用,我一直是这样用的 
       DBProcess DB = new DBProcess();
        if ( !DB.connectDatabase() )        //判断数据库连接成功
        {
    %>
            <jsp:forward page="data_err.jsp"/> 
    <%
    return;
        }
            session.setAttribute("dbprocess",DB);
    if (!DB.addUserRecord(s1,s2,s3,s4,s5,s6,s7,s8,s9))    //添加数据到数据库
            {
    %>
            <jsp:forward page="reg_user_err.jsp"/>    //如果用户已存在,返回页面错误.
    <%
            return;
            }
            
    %>
            <jsp:forward page="reg_user_ok.jsp"/>   // 注册用户成功;