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)
展开
 我来答
庄经略7s
2015-10-23 · TA获得超过155个赞
知道小有建树答主
回答量:178
采纳率:0%
帮助的人:216万
展开全部
String tmp=request.getParameter("id");

先判断下request.getParameter("id")是否获取到了东西
追问
第一句就是在判断呀
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式