Posted on 2007-10-09 11:38
leekiang 閱讀(336)
評論(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