jsp中使用SSH框架开发!list取不到值!!
我在action中写了一个方法publicActionForwardtoShow(ActionMappingmapping,ActionFormform,HttpServ...
我在action中写了一个方法
public ActionForward toShow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm messageForm = (DynaActionForm) form;
List list=messageBiz.findByActorTypeId(2); // 运行到这里就出错
request.setAttribute("message", list);
return mapping.findForward("news");
}
在逻辑层我的方法是
public List findByActorTypeId(int id){
return this.messageDAO.findByActorTypeId(Integer.valueOf(id)); //我是按字段查询的!数据库里我没有设主外键关系!!
}
实体类是自动生成的,数据库里有值!!
只要运行到那里就出错!!
java.lang.NullPointerException
at com.web.struts.action.MessageAction.toShow(MessageAction.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
断点都跳不到下一步 展开
public ActionForward toShow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm messageForm = (DynaActionForm) form;
List list=messageBiz.findByActorTypeId(2); // 运行到这里就出错
request.setAttribute("message", list);
return mapping.findForward("news");
}
在逻辑层我的方法是
public List findByActorTypeId(int id){
return this.messageDAO.findByActorTypeId(Integer.valueOf(id)); //我是按字段查询的!数据库里我没有设主外键关系!!
}
实体类是自动生成的,数据库里有值!!
只要运行到那里就出错!!
java.lang.NullPointerException
at com.web.struts.action.MessageAction.toShow(MessageAction.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
断点都跳不到下一步 展开
展开全部
1.首先打断点,看messageForm有没有值.
2.你的List没有new出来,直接是不能用的.List list = new ArrayList();
3.messageForm有值,List new对象了之后还不行的话,再在List list这一行打断点,然后跳入messageBiz.findByActorTypeId这个方法看有没有错,如果有错,说明你的messageBi调用有问题,看一下你的messageBi对象有没有注入.
4.如果还有问题,请hi我...
2.你的List没有new出来,直接是不能用的.List list = new ArrayList();
3.messageForm有值,List new对象了之后还不行的话,再在List list这一行打断点,然后跳入messageBiz.findByActorTypeId这个方法看有没有错,如果有错,说明你的messageBi调用有问题,看一下你的messageBi对象有没有注入.
4.如果还有问题,请hi我...
展开全部
messageBiz是个啥 你这编译能通过?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
java.lang.NullPointerException
messageBiz这个对象咋声明给列出来看看,别告诉我你直接用......
messageBiz这个对象咋声明给列出来看看,别告诉我你直接用......
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
messageBiz..这个东西为空了... 要不你就new 一个出来
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
NullPointerException
这个错误你可以调试下,看哪一个对象为Null ,这个错误很好找的
messageBiz 这个变量是怎么初始化的 如果用spring的话 看你是不是注入了,用了spring就不能new
这个错误你可以调试下,看哪一个对象为Null ,这个错误很好找的
messageBiz 这个变量是怎么初始化的 如果用spring的话 看你是不是注入了,用了spring就不能new
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询