为了账号安全,请及时绑定邮箱和手机立即绑定

jsp报错,大家看看

jsp报错,大家看看

qq_昼绽_0 2016-08-30 11:35:16
<%@page import="java.sql.ResultSet"%><%@ page language="java" import="java.util.*,com.jinxin.dao.LoginMaker" contentType="text/html; charset=utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">        <title>My JSP 'book.jsp' starting page</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 rel="stylesheet" type="text/css" href="styles.css"> -->  </head><!--  <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>  <script type="text/javascript">window.onload=function(){ document.getElementById("prev_page").onclick=button1;}function button1(){ }</scirpt>--><style type="text/css">*{margin:0px;padding:0px}#content{width:auto; margin:0 200px;text-align:center;border:1px solid #000;background:#CCC}table{margin:0px auto 0 auto;border-top:2px solid #999;border-left:2px solid #999; }h3{padding-left:20px;border-bottom:#FFF solid 2px;margin-top:100px}td{border-bottom:2px solid  #999;border-right:2px solid #999} </style>    <body> <div id="content"> <h3>目录 </h3>    <table>        <tr class="title">        <td>Id</td>            <td>Title</td>            <td>Author</td>            <td>UnitPrice</td>                    </tr>        <%         if(session.getAttribute("i")==null){        session.setAttribute("i",1);        }                        int i=Integer.parseInt(""+session.getAttribute("i"));        int j=8;                             for(int m=0;m<j;m++){                %>             <tr>        <td><%=LoginMaker.bookSelect(i*j-(j-1)+m).getInt(1) %>            </td>            <td><%=LoginMaker.bookSelect(i*j-(j-1)+m).getString(2) %>            </td>            <td><%=LoginMaker.bookSelect(i*j-(j-1)+m).getString(3) %>            </td>            <td><%=LoginMaker.bookSelect(i*j-(j-1)+m).getDouble(8) %>            </td>            <td><a href="book.jsp?id=<%=(i*j-(j-1)+m)%>">加入购物车</a>            </td>        </tr>        <%                }        %>    </table>    <a href="prevPage.jsp" >上一页</a>    <a href="nextPage.jsp" >下一页</a>       </div>    <div>    <table>    <%    String temp_list="";    Cookie[] cookies=request.getCookies();    for(Cookie c:cookies){    if(c.getName().equals("idList")){    temp_list=c.getValue();    }    }    temp_list=temp_list+request.getParameter("id")+",";    Cookie c =new Cookie("idList",temp_list);    String[] list =temp_list.split(",");    for(String s:list){    int m =Integer.parseInt(s);//108row,不知道哪里明明没问题啊        %>    <tr>    <td><%=LoginMaker.bookSelect(m).getInt(1) %>            </td>            <td><%=LoginMaker.bookSelect(m).getString(2) %>            </td>            <td><%=LoginMaker.bookSelect(m).getString(3) %>            </td>            <td><%=LoginMaker.bookSelect(m).getDouble(8) %>            </td>        </tr>        <%    }     %>    </table>    </div>  </body></html>错误内容:严重: Servlet.service() for servlet [jsp] in context with path [/WebPractice1] threw exception [An exception occurred processing JSP page /book.jsp at line 108105:     Cookie c =new Cookie("idList",temp_list);106:     String[] list =temp_list.split(",");107:     for(String s:list){108:     int m =Integer.parseInt(s);109:     110:     %>111:     <tr>Stacktrace:] with root causejava.lang.NumberFormatException: For input string: "null" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:492) at java.lang.Integer.parseInt(Integer.java:527) at org.apache.jsp.book_jsp._jspService(book_jsp.java:210) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744)
查看完整描述

2 回答

已采纳
?
黑女2008

TA贡献75条经验 获得超32个赞

初步怀疑你String[] list =temp_list.split(",");获取到的数组并非都可以转化成int

查看完整回答
反对 回复 2016-08-30
  • qq_昼绽_0
    qq_昼绽_0
    不是这个问题吧,我直接打开这个页面,还没有参数进来
  • 黑女2008
    黑女2008
    for(String s:list){直接打印这里的s看下}
  • qq_昼绽_0
    qq_昼绽_0
    我已经解决了, temp_list=temp_list+request.getParameter("id")+","; id这个id我没写,传进来为"",但进行这个拼接语句后,temp_list就成了"null"。
?
askshow2

TA贡献3条经验 获得超0个赞

list中有字符串为 "null"

查看完整回答
反对 回复 2016-08-30
  • 2 回答
  • 0 关注
  • 2291 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信