struts-config.xml中action元素的attribute屬性的意義
引用:http://hi.baidu.com/chenying99/blog/item/3bf7645455f6ef52574e00a4.html/cmtid/22ff23f49cfc9665dcc4747d
struts-config.xml中action元素的attribute屬性的意義
我覺得attribute還是有用的。
1)應用前提,attribute只有在設置了name后才有意義。
2)attribute可以實現對象的重用,即如果設置了attribute屬性,在創建actionform是,會先去查找相應的scope中是否有此對象,如果有,則重用,否則創建新的對象。
3)當你將創建的acitonForm保存到相應的scope中時,你想用一個更有意義的名字來訪問它時,它就有意義了。例如:
配置form.
<form-bean name="employee" type="Employee"/>
配置action:
<action
attribute="validEmployee"
name="employee"
type="EmployeeAction"
scope="request"
path="/employee">
.....
這樣就可以用validEmployee在JSP頁面中訪問了,而不是用employee.
這在同一個form 在不同情況下有不同的意義時,意義才很明顯。
posted on 2009-12-01 19:09 游雯 閱讀(475) 評論(0) 編輯 收藏 所屬分類: Java技術