MDA/MDD/TDD/DDD/DDDDDDD
posts - 536, comments - 111, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

struts笔记

Posted on 2007-10-09 11:38 leekiang 阅读(317) 评论(0)  编辑  收藏 所属分类: struts
1,ActionForm中setter和getter的类型必须对应。
   struts把post的所有参数放到一个map里,再通过beanutil的populate方法填充到ActionForm,在populate时有一些隐含逻辑,出现一些意想不到的行为,而且不同的BeanUtils版本可能还不一样。如果ActionForm的某个setter方法的参数是Long类型,而post的对应的参数的值为空,则会自动设置为0.另外ActionForm中setter和getter的类型必须对应,这个没搞明白,有空看populate()方法的源码。
2, 在ActionForm中many to one的one方可这样设置
   public String getParentid() {
        return son.getParent().getParentid().toString();
    }
   
    public void setParentid(String parentid) {
        if (parentid!= null && !"".equals(parentid)) {
            son.setParent(new Parent(new Long(parentid)));
        }
    }
3,contextRelative
如果该值被设置为 true,那么路径就被认为是相对于整个 Web 应用的相对路径。
如果该值被设置为 false,那么路径就被认为是相对于一个模块化应用程序的这个模块的相对路径。默认为false。

4,<bean:write>输入网页时必须加filter=false

5,struts1.x可以利用spring提供的RequestUtil.populate(bean)方法自动的将请求参数封装进一个POJO
见http://yuanke.javaeye.com/blog/433370

只有注册用户登录后才能发表评论。


网站导航: