jsp获取id报空指针异常 5
<%intid;try{id=Integer.parseInt(request.getParameter("id"));}catch(NullPointerExcepti...
<%
int id;
try {
id = Integer.parseInt(request.getParameter("id"));
}catch (NullPointerException e){
id = 0;
}
String procedure = "{call findById(?)}";
DBCon dbc = new DBCon();
ResultSet rs = dbc.doQuery(procedure,new Object[]{id});
if(rs.next()){
%>
报的错误是:
HTTP Status 500 - An exception occurred processing JSP page /call_edit.jsp at line 12
type Exception report
message An exception occurred processing JSP page /call_edit.jsp at line 12
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /call_edit.jsp at line 12
9: <%
10: int id;
11: try {
12: id = Integer.parseInt(request.getParameter("id"));
13: }catch (NullPointerException e){
14: id = 0;
15: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 展开
int id;
try {
id = Integer.parseInt(request.getParameter("id"));
}catch (NullPointerException e){
id = 0;
}
String procedure = "{call findById(?)}";
DBCon dbc = new DBCon();
ResultSet rs = dbc.doQuery(procedure,new Object[]{id});
if(rs.next()){
%>
报的错误是:
HTTP Status 500 - An exception occurred processing JSP page /call_edit.jsp at line 12
type Exception report
message An exception occurred processing JSP page /call_edit.jsp at line 12
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /call_edit.jsp at line 12
9: <%
10: int id;
11: try {
12: id = Integer.parseInt(request.getParameter("id"));
13: }catch (NullPointerException e){
14: id = 0;
15: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询