Spring @Autowired 不与 DWR 一起工作
这是我的服务层:
@Service
@RemoteProxy
public class ReturnToDWR{
@Autowired
private DAOLayer daoLayer;
@RemoteMethod
public List<String> returnRecord(String id){
List<String> list = daoLayer.returnPendingRecords(id);
return list;
}
}
applicationContext.xml 文件中的 DWR 配置设置:
<dwr:configuration />
<dwr:controller id="dwrController" debug="true" />
<bean id="returnToDWR" class="com.service.ReturnToDWR">
<dwr:remote javascript="returnToDWR">
<dwr:include method="returnRecord" />
</dwr:remote>
</bean>
当我从控制器调用 returnRecord()
时,它正在工作。但是当我使用 DWR 从 jsp 调用相同的方法时,它在 List
行。NullPointerException
。 list = daoLayer.returnPendingRecords(id);
我认为 spring 无法在 DWR 的情况下自动装配 private DAOLayer daoLayer;
。
请告诉我如何修复我的代码以与 DWR 一起使用?
谢谢
沙姆斯
Here is my service layer:
@Service
@RemoteProxy
public class ReturnToDWR{
@Autowired
private DAOLayer daoLayer;
@RemoteMethod
public List<String> returnRecord(String id){
List<String> list = daoLayer.returnPendingRecords(id);
return list;
}
}
DWR configuratin setting in applicationContext.xml file:
<dwr:configuration />
<dwr:controller id="dwrController" debug="true" />
<bean id="returnToDWR" class="com.service.ReturnToDWR">
<dwr:remote javascript="returnToDWR">
<dwr:include method="returnRecord" />
</dwr:remote>
</bean>
When i am calling returnRecord()
from my Controller, it is working. But when i am calling same method from jsp using DWR it shows me NullPointerException
on List<String> list = daoLayer.returnPendingRecords(id);
line.
I think spring is unable to autowire private DAOLayer daoLayer;
in the case of DWR.
Please tell me how can i fix my code to work with DWR?
Thanks
Shams
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在该行上放置制动点时,您可以在调试器中看到 daoLayer 的值确实为空吗? id 值是否有可能为 null 并导致 returnPendingRecords 方法内出现 NullPointerException?
When you place a brakepoint on that line, can you see in the debugger, that value of daoLayer is really null? Isn't it possible that the id value is null and that causes that NullPointerException inside the returnPendingRecords method?