`

spring2.5注释的不支持

阅读更多
1.spring2.5注释的不支持似乎不支持ActionForm的pojo属性的注释绑定做了通讯管理,出现了
Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Invalid argument looking up property: "address.addName" of bean: "org.apache.struts.tagli


在jsp中使用<html:text>:
<html:text property="address.addName"/>


没有错啊,actionForm确实有address对象,该对象也有addName属性
ActionForm:
public class AddressForm extends QueryConditionForm {

	//set pojo
	@Resource(name="address")
	private Address address;
         .....


这是个隐含其它异常的异常,光看异常提示,是解决不了问题的
错误提示,找不到bean.property属性实际是个假像,实际上在Spring2.5 IOC中由于采用了构造和绑定bean的注释处理,在action中处理时
address 是个延迟加载对象,照常赋值,ActionForm 的 addressForm 的 address属性没有被初始化,所以会出现上述错误
解决办法是,将bean放入formBean之前,先将其初始化.
public class AddressForm extends QueryConditionForm {

	//set pojo
	private Address address = new Address();
         .....





有些痛苦,spring2.5不支持这样写。
其实在开发中遇到类似问题。

2.spring2.5注释的不支持似乎不支持Servlet使用的注释绑定我的小组成员使用了servlet请求,也使用了spring2.5的注释技术:但在dao层出现了问题,很明显读取不到数据库的sqlMapClient(使用了ibatis技术的dataSource)。
郁闷之余,还得解决spring不支持特性;
 
ApplicationContext ctx =   
	            new ClassPathXmlApplicationContext(locations);
	       fileDiskDao = (FileDiskDao)ctx.getBean("fileDiskDao");
		FileDisk fd = new FileDisk();
		fd.setFileId(1);
		fd.setFileName("aaa");
		fd.setFileType(0);
		fd.setMaker(1);
		fd.setMakerDate(new Date());
	    fd.setParent(0);
	    fd.setPath("0");
	    fd.setFileLength("200");
	   
	    fileDiskDao.insertFile(fd);


呵呵,不知道大家是否遇到同样的问题,友们又是如何解决的呢
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics