0
我得到fornat異常號,當我試圖在的servelt接受ID JSJP頁:我得到的數字格式例外
var associates = document.getElementsByName("resourceId");
//var associates=document.getElementById(elementId).value;
var id = "";
for (var i = 0; i < associates.length; i++) {
if (associates[i].checked) {
//alert(associates[i]);
id = associates[i].value;
alert(id);
break;
}
}
我試圖從JSP文件acceptid值,並將其發送給我DAO類,但我收到的時候我試圖接受id的值數字格式例外
的Servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("in dopost");
//number format exception in this line
int associateID = Integer.parseInt(request.getParameter("id"));
if (dao.deleteAssociate(associateID)) {
System.out.println("deleted");
}
// System.out.println(associateID);
}
'的request.getParameter( 「ID」)'是指一個HTML元素與'ID = 「ID」'在JavaScript中,未命名的變量ID。 – Tricky12