2 a1206966392 a1206966392 于 2016.01.23 01:11 提问

java.lang.NumberFormatException:

刚注册没分 担待啊
这两段代码问题
int firstcount=(Integer.valueOf(currentpage)-1)*Integer.valueOf(recordpage);
int lastcount=Integer.valueOf(recordpage);

严重: Servlet.service() for servlet [BasesAction] in context with path [/sss] threw exception
java.lang.NumberFormatException: For input string: "0 "
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.valueOf(Integer.java:582)
at www.action.BasesAction.doGet(BasesAction.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
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:243)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:163)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:556)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:401)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:242)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:267)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:245)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:260)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

5个回答

caozhy
caozhy   Ds   Rxr 2016.01.23 01:21

recordpage后面多了一个空格,所以没法解析
recordpage
->
recordpage.trim()看看

rui888
rui888   Ds   Rxr 2016.01.23 15:01

For input string: "0 "

数字0 后面有空格 、

a8761087
a8761087   Rxr 2016.01.23 19:22

currentPage或recordPage中值有空格,建议转换前先判断字符串是否为null,不为null就调用trim方法清除空格

Mr_dsw
Mr_dsw   Ds   Rxr 2016.01.23 11:17

数据格式不对,所以转换错误

made_differ
made_differ   2016.01.23 11:53

recordpage变量是“0 ”,没法解析成数字。只有整数值的字符串才能转化

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!