struts整合spring,spring属性注入没有值

今天上实验课的时候让做Struts2和Spring整合实现学生管理系统,按照要求我导入了struts2和spring的jar包,然后写好了所有类,然后神奇的错误就出现了.一直提示严重 [http-nio-8080-exec-5] ,然后注入的属性为空

com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error

Exception occurred during processing request: null

 java.lang.NullPointerException

       at action.StudentAction.list(StudentAction.java:28)

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:498)

       at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)

       at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)

       at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)

       at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:117)

      at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:108)

       at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1369)

       at ognl.ASTMethod.getValueBody(ASTMethod.java:90)……………….

然后我就debug调试发现问题

struts整合spring,spring属性注入没有值_第1张图片

 

被spring管理一下,没了

struts整合spring,spring属性注入没有值_第2张图片

找了好几个小时最后发现问题

解决办法

引入spring整合struts2的jar包struts2-spring-plugin-2.3.24.jar,然后在运行数据就不会没就能运行成功了

 

你可能感兴趣的:(Java)