怎样区别一个form中的2个按钮的行为
怎样在strust中的action中区别一个form中的2个按钮的行为
------解决方案--------------------同意coolwzjcool(学习JAVA)]
如果你怕id变的话, 那你就直接传一个action的路径就可以了啊
<input type= "button " value= "按钮1 " onclick= "func_btn( '第一个按钮的action ') ">
<input type= "button " value= "按钮2 " onclick= "func_btn( '第二个按钮的action ') ">
<script>
function func_btn(actionAddress){
document.forms[0].action=actionAddress;
document.forms[0].submit();
}
</script>
------解决方案--------------------.... extends LookupDispatchAction {
protected Map getKeyMethodMap(){
HashMap map=new HashMap();
map.put( "button.delete ", "delete ");//button.delete,按钮的 message key
map.put( "button.update ", "update ");
return map;
}
public ActionForward delete(...){}//对应方法
public ActionForward update(...){}
------解决方案-------------------- <action path= "/course_search "
type= "b.b41.CourseSearchAction " name= "CourseSearchForm "
scope= "request " validate= "true "
input= "/pages/search.jsp "
parameter= "search=search, apply=apply, default=init ">
<forward name= "successInit " path= "/pages/search.jsp " />
<forward name= "success " path= "/info.do " />
</action>
注意parameter里的内容,分别对应jsp页面的search按钮和apply按钮,也对应了自己定义的Action的search和apply方法