string-java.lang.NumberFormatException:

问题描述

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)

解决方案

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

解决方案二:

For input string: "0 "

数字0 后面有空格 、

解决方案三:

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

解决方案四:

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

解决方案五:

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

时间: 2025-01-11 12:24:22

string-java.lang.NumberFormatException:的相关文章

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

java.lang.NumberFormatException: For input string: "0" 在使用JAVA IP地址转成长整型方法时出现此错误 这里对场景进行记录,以备日后遇到类似的错误,参考如何解决 错误输出: 错误原因:怀疑此处为"\0"字符 解决方法:

java.lang.NumberFormatException ... input string "0.01"

问题描述 在使用Long.parseLong("0.01")时候出现java.lang.NumberFormatException这种异常是为什么呢?难道使用使用这个方法时候只能传递整数字符串?自个基础太菜了. 解决方案 引用在使用Long.parseLong("0.01")时候出现java.lang.NumberFormatException这种异常是为什么呢?Long.parseLong,你应该去看看api嘛如果你想解决问题,看看Double.parseDoub

请教类型转换问题.java.lang.NumberFormatException 异常, 谢谢!

问题描述 public void comAccount(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {String b = req.getParameter("balance");NewCustomer customer = new NewCustomer();DAOFactory daoFactory = DAOFactory.getDAOFactory(D

ssh2-ssh中遇到java.lang.NumberFormatException

问题描述 ssh中遇到java.lang.NumberFormatException 想做一个歌曲的分页显示 出现java.lang.NumberFormatException: For input string: ""null"" java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) //按songname查找歌曲 public String getSbn(){

查询订单功能-java.lang.NumberFormatException

问题描述 java.lang.NumberFormatException java.lang.NumberFormatException: For input string: "bDate" 这是什么原因啊 ,在线急等,帮忙支支招啊大神们 解决方案 bDate不是数字,转换异常 解决方案二: 数据转换错误了,你要转换的内容不符合数值类型,自己看日志,定位错误 解决方案三: 1.错误描述 Exception in thread "main" java.lang.Num

java.lang.NumberFormatException: null

HTTP Status 500 - null type Exception report message null description The server encountered an internal error that prevented it from fulfilling this request. exception java.lang.NumberFormatException: null java.lang.Integer.parseInt(Integer.java:415

android开发-Log.d() cannnot resolve method 'd(java,lang,String java,lang,String )

问题描述 Log.d() cannnot resolve method 'd(java,lang,String java,lang,String ) android request network Log.d() cannnot resolve method 'd(java,lang,String java,lang,String )//printf message error

java.lang.NumberFormatException: null 问题

问题描述 <%java.sql.Connectiondb;Class.forName("org.gjt.mm.mysql.Driver").newInstance();db=java.sql.DriverManager.getConnection("jdbc:mysql://****","****","*****");intid=Integer.parseInt(request.getParameter("id

arraylist-java.lang.NumberFormatException: null 求大神!!

问题描述 java.lang.NumberFormatException: null 求大神!! 教师公寓与教师的关系 程序是想通过教师公寓的id获取teacher这个集合 比如几号公寓住着哪些教师 一直报转换类型错误 求大神看看 service里面的代码 public static List<Teacher> findTeacher(int id){ List<Teacher> teacher = new ArrayList<Teacher>(); SqlSessio