求助!
java.lang.NumberFormatException: For input string: "+price+"高手请进!谢谢!急!!!!!
代码如下:
while(rs.next())
{
int productsId=rs.getInt(1) ;
String productsName=rs.getString(2) ;
String productsType=rs.getString(3);
float price=rs.getFloat(4);
float priceoff=rs.getFloat(5);
String supplier=rs.getString(6) ;
String place=rs.getString(7);
int storage=rs.getInt(8);
%>
<tr>
<td bgcolor="27CCF5"><%=productsName%></td>
<td bgcolor="27CCF5"><%=productsType%></td>
<td bgcolor="27CCF5"><%=price%></td>
<td bgcolor="27CCF5"><%=priceoff%></td>
<td bgcolor="27CCF5"><%=supplier%></td>
<td bgcolor="27CCF5"><%=place%></td>
<td bgcolor="27CCF5"><%=storage%></td>
<form method="post"action="addProducts.jsp"target="cart">
<input type='hidden'name='productsId'value="+productsId+">
<input type='hidden'name='productsName'value="+productsName+">
<input type='hidden'name='productsType'value="+productsType+">
<input type='hidden'name='price'value="+price+">
<input type='hidden'name='priceoff'value="+priceoff+">
<input type='hidden'name='supplier'value="+supplier+">
<input type='hidden'name='place'value="+place+">
<td bgcolor="27CCF5"><input type='text'name='number'size=8></td>
<td bgcolor="27CCF5"><input type='submit'value='购买'></td>
</form>
</tr>
出现以下问题,看了半天了,都不知道哪里错了,按理说+price+这里没错的啊,请高手指点!
exception
org.apache.jasper.JasperException: For input string: "+price+"
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NumberFormatException: For input string: "+price+"
sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
java.lang.Float.valueOf(Float.java:360)
java.lang.Float.<init>(Float.java:461)
org.apache.jsp.client.addProducts_jsp._jspService(addProducts_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
------解决方案--------------------float price=rs.getFloat(4); // float类型
<input type='hidden'name='price'value="+price+"> // String类型
==》格式化错误,float类型的属性不能赋予String类型的值。
------解决方案--------------------试试把你的那个属性放到setAttribute中,再拿出来试试
------解决方案--------------------可能你的数据有问题
------解决方案--------------------<input type='hidden'name='price'value="+price+">
中+price+什么意思,没看懂这样