问题描述
- HTTP Status 500 - For input string: "3.0"
-
我在做一个增加数据功能的网页,测试时出现了错误提示如下(输入整型数据时不报错,但是输入浮点型数据时却报错):
java.lang.NumberFormatException: For input string: "2.0"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
example4.Insert.doPost(Insert.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)note The full stack trace of the root cause is available in the Apache Tomcat/7.0.68 logs.
相关代码如下:
view界面代码:
X: Y: javabean代码:
//获取前台页面数据
String x3 =request.getParameter("x");double x = Double.parseDouble(x3); String y1 =request.getParameter("y"); double y = Double.parseDouble(y1); 我是新手,请各位大神帮我诊断一下,感激不尽!
解决方案
type?Exception report
message?For input string: " 1"
description?The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NumberFormatException:......
答案就在这里:HTTP Status 500 - For input string: " 1"
解决方案二:
http://bbs.csdn.net/topics/390946182
时间: 2024-09-29 17:15:49