我的网站放在D:\software engneering文件下,名为“jsp15”在该网站下的2个文件:search_result.jsp和pageman.jsp都放在:D:\software engneering\jsp15\WebRoot\back_manage文件夹下
我在search_result.jsp中调用pageman.jsp:search_result.jsp中的代码如下:
<%@ include file="back_manage/pageman.jsp" %>
<%@ include file="../back_manage/pageman.jsp" %>
<%@ include file="/jsp15/back_manage/pageman.jsp" %>都是错误,无法执行,请教高手,该怎么写?

解决方案 »

  1.   

    直接用<%@include file="pageman.jsp"%>试下
      

  2.   

    @include 下的路径为你站点的根目录,比如:http://localhost:8080/jsp15 
    此时你的网站根路径应该是jsp15吧,那么你因该这样引用上述jsp文件
    <%@ include file="/WebRoot/back_manage/pageman.jsp" %> //绝对路径写法
    <%@ include file="../../back_manage/pageman.jsp" %> //相对路径写法楼主可以试一下
      

  3.   

    按说同一个路径下的文件包含,直接写名字即可,也就是1L的写法。至于LZ说错了,你得把错误打印出来看是什么?
    jsp互相包含很容易引进变量重复定义的情况(假设jsp中用了java脚本)
      

  4.   


    绝对路径显示如下错误:
    org.apache.jasper.JasperException: /back_manage/search-result.jsp(102,3) File "/WebRoot/back_manage/pageman.jsp" not found
    相对路径显示如下错误:<%@ include file="../../back_manage/pageman……An error occurred at line: 22 in the jsp file: /back_manage/../../back_manage/pageman.jsp
    Cannot make a static reference to the non-static field PageBean.rowsPerPage都快崩溃了,都两天了。
    请教高手,帮忙解答!
      

  5.   


    一楼的错误如下:
    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 22 in the jsp file: /back_manage/pageman.jsp
    Cannot make a static reference to the non-static field PageBean.rowsPerPage
      

  6.   

    一楼的方法更详细的错误:
    1 首先是在Myeclipse中有小红叉提示错误
    2 编译运行错误如下:
    org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 22 in the jsp file: /back_manage/pageman.jsp
    Cannot make a static reference to the non-static field PageBean.rowsPerPage
    19: -->
    20: </script>   
    21: <body>
    22: 每页<%=PageBean.rowsPerPage%>行
    23: | 共<%=PageBean.maxRowCount %>行
    24: | 第<%=PageBean.curPage %>页
    25: | 共<%=PageBean.maxPage%>页 
    An error occurred at line: 23 in the jsp file: /back_manage/pageman.jsp
    Cannot make a static reference to the non-static field PageBean.maxRowCount
    20: </script>   
    21: <body>
    22: 每页<%=PageBean.rowsPerPage%>行
    23: | 共<%=PageBean.maxRowCount %>行
    24: | 第<%=PageBean.curPage %>页
    25: | 共<%=PageBean.maxPage%>页 
    26: <br>
      

  7.   

    22: 每页<%=PageBean.rowsPerPage%>行
    23: | 共<%=PageBean.maxRowCount %>行
    24: | 第<%=PageBean.curPage %>页
    25: | 共<%=PageBean.maxPage%>页 楼主你的全部是静态变量。怎么弄的分页。
      

  8.   

    <%@ include file="/jsp15/back_manage/pageman.jsp" %>这种是静态包含file里只能是HTML的文件,而你的是JSP。如果pageman.jsp发生了改变,它不会去检测该文件的变化。
    你应该采用<jsp:include page="/jsp15/back_manage/pageman.jsp">
    这种是动态包含page里可以是HTML和JSP的文件,如果pageman.jsp发生了改变,它会去检测该文件的变化。这就是两种include的区别!
      

  9.   

    肯定可以呀!
    WEB-INF下的用户不能访问到!
      

  10.   


    我改成<jsp:include page="/jsp15/back_manage/pageman.jsp">但是有的页面好用,有的页面又出现了如下错误:org.apache.jasper.JasperException: javax.servlet.ServletException: File &quot;/jsp15/back_manage/pageman.jsp&quot; not found org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    请教,到底怎么回事?
      

  11.   

    <jsp:include page="/jsp15/back_manage/pageman.jsp">
    你忘记了结束标签</jsp:include>
    页面上不是有个path吗?建议不要写死了!
    <%=path>/back_manage/pageman.jsp
      

  12.   


    iutianxiong888
    你好,非常感谢你的热心回复!
    我刚才写错了,我已经改成:<jsp:include page="/jsp15/back_manage/pageman.jsp"/>
    即它等价于你的答案:<jsp:include page="/jsp15/back_manage/pageman.jsp">  </jsp:include> 还是会出现错误: 
    org.apache.jasper.JasperException: javax.servlet.ServletException: File &quot;/jsp15/back_manage/pageman.jsp&quot; not found 但是,我改成:
    <jsp:include page="/jsp15/back_manage/pageman.jsp" flush="true"/>就对了,这是为什么啊?
      

  13.   

    flush="true"这可以不要吧!
    但是后面的/必须要,表示标签结束
      

  14.   


    书本上说:
    flush=true时,表示在包含目标资源前,先刷新当前页面输出缓冲区中的内容;
    flush=false时,包含文件前,不刷新当前页面的输出缓冲区。
    我的确是加了flush="true",页面才正常了。
      

  15.   

    Quote=引用 17 楼 ggxxkkll 的回复:]
    引用 16 楼 liutianxiong888 的回复:
    flush="true"这可以不要吧!
    但是后面的/必须要,表示标签结束
    书本上说:
    flush=true时,表示在包含目标资源前,先刷新当前页面输出缓冲区中的内容;
    flush=false时,包含文件前,不刷新当前页面的输出缓冲区。我的确是加了flush="true",页面才正常了。
    [/Quote]默认情况下是:flush=false.
      

  16.   

    那就奇怪了,flush这个我就从来没用过!
    代码贴全一点看看!
      

  17.   

    {0}
    <%@ page language="java" pageEncoding="gbk"%>
    <%@ page import="java.util.*"%>
    <jsp:useBean id="pagebean" class="bbsbean.PageBean" scope="request"/>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head> <title>浏览所有用户</title> <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link type="text/css" rel="stylesheet" href="style/m1.css" />
    </head> <body>
    <div  style="MARGIN-BOTTOM:15px" align="center"  ><font style="font:30px bold '宋体';MARGIN-BOTTOM:50px" color="#3d39d1">t大学生互助交流论坛后台管理系统</font></div>
    <div  id=tableCell
    style='PADDING-TOP: 15px; PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 15px; text-align: center;'>
    <table width="90%" border="0" cellspacing="1" cellpadding="5"
    align="center" id="tableArea" style="margin-top:10px">
    <tr id="tableTitle">
    <td align="center">
    用户名
    </td>
    <td align="center">
    Email
    </td>
    <td align="center">
    发帖数
    </td>
    <td align="center">
    注册时间
    </td>
    <td align="center">
    最后活动时间
    </td>
    <td align="center">
    动作
    </td>
    </tr>



    <%
    Vector v = pagebean.getResult();

    if(v!=null){
    Enumeration e = v.elements();

    while(e.hasMoreElements()){
    Object[] obj = (Object[])e.nextElement();
    %>

    <tr id="tableCell" style="text-align:center">
    <td>
    <%=obj[1] %>
    </td>
    <td>
    <%=obj[5] %>
    </td>
    <td>
    <%=obj[14] %>
    </td>
    <td>
    <%=obj[18].toString() %>
    </td>
    <td>
    <%=obj[22].toString() %>
    </td>
    <td>
    <a href="userservlet?button=edit&userid=<%=obj[0]%>"><span>编辑</span></a> |
     <a href="userservlet?button=delete&userid=<%=obj[0]%>&uroleid=<%=obj[4]%>"><span>删除</span></a>
    </td>
    </tr>


    <%}}else{System.out.println("为空");}%>

    </table>
    <br />
    <%if(pagebean.maxPage>1){ %>
    <form name="PageForm" action="userviewservlet" method="post">
    <jsp:include page="/jsp15/back_manage/pageman.jsp" flush="true"/>
    </form>
    <%}%>
    </div>
    <br />
    <jsp:include page="bottom-info.jsp" flush="true"></jsp:include>
    </body>
    </html>
     
    这是代码,在倒数第11行:<jsp:include page="/jsp15/back_manage/pageman.jsp" flush="true"/>我也很奇怪,这样一改,页面就正常了!
    到底是为什么啊???
      

  18.   

    对于你的代码,我看起来比较吃力!
    <jsp:include page="bottom-info.jsp" flush="true"></jsp:include>
    这里如果不用flush可以吗?
    放在一个form中的写法我没有做过!