日期:2014-05-20  浏览次数:20900 次

NumberFormatException 错误求教高手!!
exception 

javax.servlet.ServletException: For input string: "246.0"
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.lang.NumberFormatException: For input string: "246.0"
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:456)
java.lang.Integer.parseInt(Integer.java:497)
com.yourcompany.struts.action.VehicleinfoAction.check_out(VehicleinfoAction.java:331)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

我做了好久总是报以上错误,这是怎么回事要怎么解决呀。

这是我的源代码
String cardid=vehicleinfoForm.getCardid();
String endtime=request.getParameter("endtime");
String starttime=request.getParameter("starttime");

HttpSession session=request.getSession();
String mon=(String) session.getAttribute("money");

Float money=Float.valueOf(Integer.parseInt(mon.trim()));
VehicleDAO dao=new VehicleDAO();

------解决方案--------------------
Integer.parseInt(mon.trim())可能这里转化出错字符串带小数点不能转成整数
类型转换的错误
------解决方案--------------------
Float money=Float.parseFloat(mon.trim()); 

------解决方案--------------------
Integer.parseInt("246.0")
类型转换错误
------解决方案--------------------
探讨
Integer.parseInt(mon.trim())可能这里转化出错字符串带小数点不能转成整数
类型转换的错误