struts1中配置应用

*列表收集ID集合时,在formbean中放一个String[] selectFlag;数组,这时提交时formbean会自动收集
---------------------------------
function deleteUser() {
var flag = false;
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
if (document.getElementsByName("selectFlag")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的用户!");
return;
}
if (window.confirm("确认删除吗?")) {
with (document.getElementById("userForm")) {
method = "post";
action = "del.do";
submit();
}
}
}
---------------------------------


*直接将值放到REQUEST中,前台用EL或标签显示出来
BeanUtils.copyProperties(user, uaf);//user为bean uaf是formbean

* ActionForward(转向)
动态的ActionForward
ActionForward af = new ActionForward();
af.setPath("/page"+page + ".jsp?name=tom");
retrun af;//只要最后返回一个forward就可以了

*声明式异常
<action-mappings>
<action path="/login"...>
<exception key="user.not.found" type="com.bving.struts.UserNotFoundException"/> //这里的key是在国际化文件中配置的
<forward>...
</action-mapping>

* DispatchAction重要的
在ACTION中需要实现DispatchAction中的execute()方法,最后一定要调用super.
---------------------------------
<action-mappings>
<action path="/user/usermaint"
type="com.bjsxt.drp.web.usermgr.actions.UserAction"
name="userForm"
scope="request"
parameter="command"
>
<!--
<forward name="add_success" path="/user/usermaint.do?command=list" redirect="true"/>
<forward name="del_success" path="/user/usermaint.do?command=list" redirect="true"/>
<forward name="modify_success" path="/user/usermaint.do?command=list" redirect="true"/>
-->
<forward name="find_success" path="/user/user_modify.jsp"/>
<forward name="list_success" path="/user/user_list.jsp"/>
</action>
---------------------------------

 

posted @ 2012-02-06 14:42  cyjch  阅读(423)  评论(0编辑  收藏  举报