关于jsp中异常问题
这个是我jsp中的代码<%
Dept vc=new Dept();
vc.setDeptno(Integer.parseInt(request.getParameter("deptno")));
vc.setDname(request.getParameter("dname"));
vc.setLoc(request.getParameter("loc"));
String msg="部门添加失败";
boolean a=ServiceFactory.getIDeptService().insert(vc);
if(a){
msg="部门信息添加成功";
}
%>
下面是他显示的错误
org.apache.jasper.JasperException: An exception occurred processing JSP page /pages/back/admin/dept/dept_insert_do.jsp at line 33
30: %>
31: <%
32: String msg="閮ㄩ棬娣诲姞澶辫触";
33: boolean a=ServiceFactory.getIDeptService().insert(vc);
34: if(a){
35: msg="閮ㄩ棬淇℃伅娣诲姞鎴愬姛";
36: }
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
cn.impl.www.DeptDAOImpl.findById(DeptDAOImpl.java:59)
cn.impl.www.DeptDAOImpl.findById(DeptDAOImpl.java:1)
cn.service.impl.www.DeptServiceimpl.insert(DeptServiceimpl.java:16)
org.apache.jsp.pages.back.admin.dept.dept_005finsert_005fdo_jsp._jspService(dept_005finsert_005fdo_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
然而我在dao类测试代码,在dao类中没有问题呀
@Test
public void testDoCreate() {
Dept vo =new Dept();
vo.setDeptno(11);
vo.setDname("哈哈");
vo.setLoc("呵呵");
try {
TestCase.assertTrue(ServiceFactory.getIDeptService().insert(vo));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}