关于struts2和hibernate一个菜鸟菜鸟级的问题!
[
color=#000000]1.这个是异常代码:
严重: Exception occurred during processing request: null
java.lang.reflect.InvocationTargetException
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 com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
2.下面是action代码:
private userinfoDAOImpl userDAOImpl=new userinfoDAOImpl();
public String execute()throws Exception{
userDAOImpl.addUserinfo(user);
return "success";
}
3.下面是DAO接口的实现
public void addUserinfo(userinfo user) {
Session s=null;
Transaction tx=null;
try{
s=myUtil.getSession();
tx=s.beginTransaction();
s.save(user);
tx.commit();
}catch(Exception e){
if(tx!=null)
tx.rollback();
//throw e;
}finally{
if(s!=null)
s.close();
}
}
麻烦大家帮我看看,是哪里出了问题?
小弟在此先谢过了!!!
------解决方案--------------------catch (Exception e) {
if(e instanceof
InvocationTargetException){
throw ((Invocation
TargetException) e).getTargetException();
}else{
//doXXX()
}
}
在异常作一个这样的处理。。再进行检查。。。
------解决方案--------------------你给的代码不够,只知道是请求为空,反射异常!你最好把你的struts2和hibernate的配置文件贴出来我们看看,这样就更能清楚问题出在哪里!
给你一些参考资料
http://doc.java.sun.com/DocWeb/api/all/java.lang.reflect.InvocationTargetException
http://zhidao.baidu.com/question/203108968.html