首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSP分页有关问题,啊 高人指点

2013-09-11 
JSP分页问题,急啊 在线等高人指点%@pagecontentType text/htmlcharsetgb2312 %%@includefile co

JSP分页问题,急啊 在线等高人指点
<%@   page   contentType= "text/html;charset=gb2312 "%>
<%@   include   file= "conn.jsp "%> //数据库的连接和相关定义
<html>
<head> <title> 通讯录 </title>
</head>
<body   background= "image/zuobian.jpg ">

<a   href= "index.jsp "> 返回 </a>
<%int   ZGBH=0;
  String   zh=(String)session.getAttribute( "ZGBH ");//zgbh   为用户的编号,同过他找到用户的通讯录
  if(zh!=null){
  ZGBH=Integer.parseInt(zh);
  if(request.getParameter( "flag ")==null){//如果没有查询就输出通讯录表

%>
<table   class= "tab "   width= "97% "   align= "center "   cellspacing=1   cellpadding=5   bgcolor=#999999   style= "word-break:break-all; ">
    <tr>
  <form   name= "chacun "   method= "post "   action= "tliebiao.jsp ">
        <td   colspan= "7 "   align= "right "   bgcolor= "#66CCFF "   >   按姓名查找
                <input   name= "lxrxm "   type= "text "   >
                <input   type= "submit "   name= "submit "   value= "查询 "/> </td> <input   type= "hidden "   name= "flag ">
</FORM>


    </tr>
    <tr   bgcolor= "#2969b5 "   height= "22 ">
        <td     width=8%   align=center   bgcolor= "#66CCFF "   > <font   color= "#ffffff "   > <b> 姓名 <img   src= "image/tou.bmp "   /> </b> </font> </td>
        <td     width=12%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 移动电话 </b> </font> </td>
        <td     width=12%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 邮件 </b> </font> </td>
        <td     width=12%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 办公电话 </b> </font> </td>
        <td     width=15%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 工作单位 </b> </font> </td>
        <td     width=19%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 家庭地址 </b> </font> </td>
        <td     width=12%   align=center   bgcolor= "#66CCFF "> <font   color= "#ffffff "> <b> 操作 </b> </font> </td>
    </tr>
    <tr   bgcolor=#ffffff>
        <td   colspan=6   height=15> </td>
        <td   width= "10% "align= "center "   title= "新增成员 "> <a   href= "txinjia.jsp?ZGBH= <%=ZGBH%> "> <font   size=2> 新增联系人 </font> </a> </td>


    </tr>
    <%
  int   curpage=1;//当前页  
int   page_record=6;//每页显示的记录数  
curpage=Integer.parseInt(request.getParameter( "page "));//获取传递的值,需要显示的页   //也就是这里老报错说里面的为NULL   不知道怎么解决
String   sql= "select   top   "+page_record+ "   *   from   ZZ_TXLB   where   ZGBH= ' "+ZGBH+ " '   and   LXRXH     not   in   (select   top   "+(curpage*page_record)+ "   *   form   ZZ_TXLB   where   ZGBH= ' "+ZGBH+ " ') ";  
rs=stmt.executeQuery(sql);    
  int   lxrxh=0;
    while(rs.next()){          
    lxrxh=rs.getInt(1);
%>
    <tr   align= "center "   valign= "middle "   bgcolor= "#FFFFFF ">   </tr>
    <tr     bgcolor= "#999999 "   align=center>
        <td   align=center   bgcolor= "#d0e7ff "> <font   size=2> <%=rs.getString( "LXRXM ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> &nbsp; <font   size=2> <%=rs.getString( "YDDH ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> &nbsp; <font   size=2> <%=rs.getString( "EMAIL ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> &nbsp; <font   size=2> <%=rs.getString( "BGDH ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> &nbsp; <font   size=2> <%=rs.getString( "GZDW ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> &nbsp; <font   size=2> <%=rs.getString( "JTDZ ")%> </font> </td>
        <td   bgcolor= "#d0e7ff "> <a   href= "tgenggai.jsp?LXRXH= <%=lxrxh%> "> <font   size=2>   改 </font> </a> | <a   href= "tshanchu.jsp?LXRXH= <%=lxrxh%> "> <font   size=2> 删除 </font> </a> </td>
    </tr>
    <tr>
        <td   colspan= "7 "   height= "3 "   bgcolor= "#FFFFFF "> </td>
    </tr>
        <%     }
  %>
 
</table>
<center>
  <form     method= "POST "   action= "tliebiao.jsp ">   //提叫本页处理


<%if(curpage> 0){%> <a  

href= "tliebiao.jsp?page= <%=curpage+1%> "> 下一页  

</a> <%}%>   <%if(curpage> 1){%> <a   href= "tiliebiao.jsp?page= <%=curpage-1%> ">  

上一页 </a> <%}%>  
转到第: <input   type= "text "   name= "page "   size= "8 ">   页  
<span> <input   type= "submit "   name= "Submit "   value= "GO "   /> </span>  
</form>    
</center>
<%
}else{//如果有查询就弹出小窗口显示查询结果


      String   LXRXM=request.getParameter( "lxrxm ");
    byte[]   tmpbyte=LXRXM.getBytes( "ISO8859_1 ");
    LXRXM=new   String(tmpbyte);%>
  <script   language= "javascript ">
function   load()
        {        
    window.open( "tchaxun.jsp?LXRXM= <%=LXRXM%> ", "toolbar=no,menubai=no,width=100,height=100 ");
        }
      </script>
      <body   onLoad= "load() ">
<%}
  stmt.close();  
    conn.close();
}
  %>
</body>
</html>


报错信息
org.apache.jasper.JasperException:   An   exception   occurred   processing   JSP   page   /tliebiao.jsp   at   line   40

37:           <td   colspan=6   height=15> </td>
38:           <td   width= "10% "align= "center "   title= "新增成员 "> <a   href= "txinjia.jsp?ZGBH= <%=ZGBH%> "> <font   size=2> 新增联系人 </font> </a> </td>
39:       </tr>
40:       <%
41:     int   curpage=1;//当前页  
42:   int   page_record=6;//每页显示的记录数  
43:   //用下面的方法(sql查询完成,速度快)

java.lang.NumberFormatException:   null

它报错40行   我想是后面的得到的为空


请高手指点



[解决办法]
curpage=Integer.parseInt(request.getParameter( "page "));//获取传递的值,需要显示的页 //也就是这里老报错说里面的为NULL 不知道怎么解决

改为
String Page =request.getParameter( "page ");
if(Page==null)
{
curpage=1;
}else
{
curpage=Integer.parseInt(Page);
}
再试试!!!
[解决办法]
String Page =request.getParameter( "page ")==null? "1 ":request.getParameter( "page ");
[解决办法]

curpage=Integer.parseInt(request.getParameter( "page "));//获取传递的值,需要显示的页 //也就是这里老报错说里面的为NULL 不知道怎么解决

前面要加个判断,因为页面初始化的时候没有传递page这个参数,所以会出错,判断如下:

if(null != request.getParameter( "page "))
{
curpage=Integer.parseInt(request.getParameter( "page ").toString());
}
[解决办法]
String Page =request.getParameter( "page ")==null? "1 ":request.getParameter( "page ");

这样写。顶楼上的
[解决办法]
curpage=Integer.parseInt(request.getParameter( "page "))
改成curpage=Integer.parseInt((String)request.getParameter( "page "))试试

我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html

热点排行