您好我希望从表单中获取用户年龄并将该字符串转换为 int 并在 java 类中的其他位置使用
.jsp 片段看起来像这样
<%
String str = request.getParameter("age");
int convertInt = Integer.parseInt(str);
%>
<% myProgram.comAvgerage(convertInt);%>
但是我收到 HTTP 状态 500 - java.lang.NumberFormatException: null
我认为这是因为表单首先在 UI 类中创建,因此字段为 null ?
这是错误吗,我可以解决这个问题吗?谢谢