SSH编程报了个
空指针严重: Servlet.service() for servlet action threw exception
java.lang.NullPointerException
at com.dianxun.action.SendTieziAction.execute(SendTieziAction.java:54)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
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.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)
Action里的代码:public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
SendTieziForm sendForm = (SendTieziForm) form;
int id =Integer.parseInt(sendForm.getXid());
String contxtString = sendForm.getTxtCon();
String username = sendForm.getUname();
System.out.println(id+","+contxtString+","+username);
ArrayList<Topic> list= personService.getTopicDate("from Topic where id = "+id);//这里报空指针了
Topic topic2 = new Topic();
topic2.setParented(id);
topic2.setFroumid(list.get(0).getFroumid());
topic2.setUsername(username);
topic2.setTzcontent(contxtString);
Timestamp t = new Timestamp(new Date().getTime());
topic2.setFtimes(t);
personService.save(topic2);
return null;
}
getTopicDate方法:
public ArrayList<Topic> getTopicDate(String sqlString)
{
ArrayList<Topic> list = new ArrayList<Topic>();
Query query = sessionFactory.getCurrentSession().createQuery(sqlString);
List<Topic> list2