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

求助!第一次点击商品存入cookie中的内容是一串奇怪的字符串

运行时报错:

java.lang.NumberFormatException: For input string: "BB318C07B1B138D5500ECA16365941764"

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

at java.lang.Integer.parseInt(Integer.java:447)

at java.lang.Integer.parseInt(Integer.java:497)

at dao.ItemsDAO.getViewList(ItemsDAO.java:151)

at org.apache.jsp.details_jsp._jspService(details_jsp.java:221)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:472)

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:728)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:444)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:319)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:619)


通过输出cookie中的内容发现第一次点击商品时,存入cookie中的值是形如"BB318C07B1B138D5500ECA16365941764"的字符串,所以在执行Integer.parseInt(arr[i])时会抛出异常。

但是多点击几个商品,查看cookie中保存的内容又是正确的:"BB318C07B1B138D5500ECA16365941764#1#4#2#2#2#1".

导致点击商品次数超过5次才不会报错(因为不会将第一个神奇的字符串转换成数字了)

太奇怪了!为什么第一次点击商品时存入cookie中的值会是个字符串呢???

正在回答

2 回答

感觉是默认编码不对,你这16进制的

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

求助!第一次点击商品存入cookie中的内容是一串奇怪的字符串

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信