我用的框架是spring+ibatis+struts1
我的action调用service的时候提示空指针异常,我怀疑是没有注入的问题,但找了半天没有找出错误.希望各位高手帮帮小弟!
action Class codeprivate ITestService testService;
public ITestService getTestService() {
return testService;
}
public void setTestService(ITestService testService) {
this.testService = testService;
}......public ActionForward getUserList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
List testList = testService.doselectall();//这里报错 空指针异常
request.setAttribute("testList", testList);
return mapping.findForward("list");
}service class codeprivate ITestDao testDao;
public ITestDao getTestDao() {
return testDao;
} public void setTestDao(ITestDao testDao) {
testDao = testDao;
}...... public List doselectall() {
return testDao.doselectall();
}spring.xml code <bean id="testDao" class="com.dne.a.persistence.TestDao">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<bean id="testService" parent="baseTransactionProxyforIbatis">
<property name="target">
<bean class="com.dne.a.service.TestService">
<property name="testDao" ref="testDao" />
</bean>
</property>
</bean>一早上看的头都晕了,也没发现哪里错了,很纠结啊!
我的action调用service的时候提示空指针异常,我怀疑是没有注入的问题,但找了半天没有找出错误.希望各位高手帮帮小弟!
action Class codeprivate ITestService testService;
public ITestService getTestService() {
return testService;
}
public void setTestService(ITestService testService) {
this.testService = testService;
}......public ActionForward getUserList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
List testList = testService.doselectall();//这里报错 空指针异常
request.setAttribute("testList", testList);
return mapping.findForward("list");
}service class codeprivate ITestDao testDao;
public ITestDao getTestDao() {
return testDao;
} public void setTestDao(ITestDao testDao) {
testDao = testDao;
}...... public List doselectall() {
return testDao.doselectall();
}spring.xml code <bean id="testDao" class="com.dne.a.persistence.TestDao">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<bean id="testService" parent="baseTransactionProxyforIbatis">
<property name="target">
<bean class="com.dne.a.service.TestService">
<property name="testDao" ref="testDao" />
</bean>
</property>
</bean>一早上看的头都晕了,也没发现哪里错了,很纠结啊!
解决方案 »
- 帮忙转换sql语句到hql语句
- 一个SESSION的事务处理100条记录,然后关闭在开,每次在开一个新的事务处理是否都会刷新HIBERNATE缓存?
- struts+ibatis问题
- struts2.0中如何使用Ajax方式进行查询并在页面局部显示查询结果列表
- Struts 1.3.8要安装哪个?怎么安装
- Broken Pipe是什么意思?
- ActionServlet.initModulePlugIns(ActionServlet.java:880)?
- 一个挺麻烦的小问题:怎样在struts的翻页中保存checkbox的状态
- 高分求助,如何在jsp程序中,生成一个日志文件!!!
- java socket发送byte数组能成功 netty框架不行
- 模糊查询
- 江湖救急
这样你的spring和struts 并没有关联起来
别生气我新手可能很多搞混淆或则搞不明白,你能简单的解释下吗?
class="com.dne.a.action.TestAction">
<property name="testService" ref="TestService" />
</bean>
private ITestDao testDao;
......
public List doselectall() {
return testDao.doselectall();
}这个方法,挺好玩的