,我能修复吗
嗨,我想从表单中获取用户年龄,并将该字符串转换为int,然后在java类的其他地方使用
.jsp片段看起来像这个
<%
String str = request.getParameter("age");
int convertInt = Integer.parseInt(str);
%>
<% myProgram.comAvgerage(convertInt);%>
然而,我得到了HTTP状态500-java.lang.NumberFormatException:空
我认为这是因为表单是首先在UI类中创建的,因此字段为空?
这是故障吗?感谢
这表明request.getParameter("age")返回null。这意味着没有通过表单提交的名为"年龄"的参数。请检查以确保"年龄"是表单参数的名称。即input type="text"id="parameter"name="年龄"value="test"
他们必须匹配,确保案件也匹配。