我有一个 HTML 代码:
表格 输入类型=“文本”名称=“ad4”值=“9” 输入类型=“提交”值=“测试电子邮件” 形式(故意去掉尖括号)
然后是我的 JPS 代码:
String test = request.getParameter("ad4");
int testb = Integer.parseInt(test);
out.print("Your test is: " + test);
out.print("Your Test conversão é: " + testb);
%>
它给出错误消息:HTTP Status 500 - 处理 JSP 页面时发生异常
最佳答案
您必须检查 jar 文件或 maven。
以下内容工作正常。
index.jsp
<form action ="show.jsp" action="GET" >
<input type="text" name = "ad4" value="9" >
<input type="submit" value="Test">
</form>
show.jsp
String test = request.getParameter("ad4");
int testb = Integer.parseInt(test);
out.print("Your test is: " + test);
out.print("Your Test conversão é: " + testb);
%>
关于java - 从字符串到整数的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60198956/