问题描述
HTTPStatus500---------------------------------------------------------------------------------typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionorg.apache.jasper.JasperException:ExceptioninJSP:/Delete.jsp:4037:38:<%39:intid=Integer.parseInt(request.getParameter("id"));40:intpid=Integer.parseInt(request.getParameter("pid"));41:42:Class.forName("com.mysql.jdbc.Driver");43:Stringurl="jdbc:mysql://localhost/bbs?user=root&password=root";Stacktrace:org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rootcausejava.lang.NumberFormatException:nulljava.lang.Integer.parseInt(UnknownSource)java.lang.Integer.parseInt(UnknownSource)org.apache.jsp.Delete_jsp._jspService(Delete_jsp.java:82)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)javax.servlet.http.HttpServlet.service(HttpServlet.java:729)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:257)javax.servlet.http.HttpServlet.service(HttpServlet.java:729)noteThefullstacktraceoftherootcauseisavailableintheApacheTomcat/5.5.29logs.
解决方案
解决方案二:
java.lang.NumberFormatException:null数字格式异常!!intpid=Integer.parseInt(request.getParameter("pid"));request.getParameter("pid"))的值为空。一个空值转换成Int类型出错,引起的异常:java.lang.NumberFormatException:null
解决方案三:
intid=Integer.parseInt(request.getParameter("id"));intpid=Integer.parseInt(request.getParameter("pid"));加一个判断intid=Integer.parseInt(request.getParameter("id")==null?"1":request.getParameter("id"));intpid=Integer.parseInt(request.getParameter("pid")==null?"1":request.getParameter("pid"));
解决方案四:
2楼正解,检查检查你传值的那个页面吧
解决方案五:
在二楼的基础上说点个人的小建议把要判断的空值或者空字符串放在等式的左边这样最少可以避免空指针