ssh2发帖功能实现不了 求大虾指教
action:
public String execute() throws Exception {
Map session = ActionContext.getContext().getSession();
String username = (String) session.get("username");
//封装一个model类的对象
Article article = new Article();
article.setTitle(title);
article.setContent(content);
article.setUsername(username);
article.setDate(new Date());
article.setHasread(0);
articleService.addArticle(article);
return "success";
}
daoImpl:
public void add(Article article) {
this.getHibernateTemplate().saveOrUpdate(article);
}
错误提示是:
java.lang.NullPointerException com.hss.dao.impl.ArticleDAOImpl.add(ArticleDAOImpl.java:24)
com.hss.service.impl.ArticleServiceImpl.addArticle(ArticleServiceImpl.java:39)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy14.addArticle(Unknown Source)
com.hss.action.AddArticle.execute(AddArticle.java:46)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
太多了 后面就不贴了。。
------解决方案--------------------daoImpl这个你实例化了没有啊,你用的什么框架啊,只是struts2,hibernate,的话,就要实例化一下类,才能用到啊
------解决方案--------------------从错误处可以看到,
com.hss.service.impl.ArticleServiceImpl.addArticle(ArticleServiceImpl.java:39)
39行,也就是articleService.addArticle(article);这个报
java乘法表格式不标准怎么处理