gpt4 book ai didi

java - request.getParameter 获取 java.lang.NumberFormatException : null

转载 作者:行者123 更新时间:2023-11-30 10:30:15 25 4
gpt4 key购买 nike

<分区>

我有一个从 SQL 表中提取数据的下拉菜单。一切正常,我可以选择值并提交表单。但是,当我从 String 转换值时,我的 scriptlet 给出了 NULL 异常。我做错了什么?

testCars.jsp

<form method=post action=“testCars.jsp">
<div class="cell">
Select CarID
<div class="input-control select mutiple full-size">
<select id=“carID” name=“carID” onchange="listCarIDFromDatabase();”>
<option selected disabled>--SELECT--</option>
<%
ArrayList<Integer> result = carDAO.getCarID(Integer.parseInt(id));
for (int r: result){
out.println("<option value='" + r + "'>" + r + "</option>");
request.setAttribute("r", r);
}
%>
</select>

</div>
</div>

输入的returncarID根据AJAX成功填充onchange="listCarIDFromDatabase();

   <button class="button primary" type="submit">Generate</button></form>
<input name=“returncarID” id=“returncarID”>


<%
//Scriptlet gets the value of the dropdown in next line, but when I convert to Int it is NULL
String y = request.getParameter(“returncarID”);
out.println(y); <——Prints out value here

int x = Integer.parseInt(y);
out.println(x); <———Null Exception here


%>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com