struts中的form提交问题 在action里面根据按钮的值来判断点击了那个按钮 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 当有多个提交按钮时,可采用Button按钮,一般是用JavaScript处理成所需要的提交格式,再进行提交,这些实现方法本身与Struts无关。具体的做法网上有许多资料和例子。 1:button<tr> <td colspan = "14" align = "right" > <input name = "Button2" type = "button" class = "ListButton" onClick = "set('add')" value = "新增"> <input name = "Button2" type = "button" class = "ListButton" onClick = "set('modify')" value = "修改"> <input name = "Button2" type = "button" class = "ListButton" onClick = "set('delete')" value = "删除"> </td></tr>2:javascriptfunction set(method){ if(method == 'modify'||method == 'delete'){ if(validate()){ form1.method.value = method; form1.submit(); }else{ alert("至少选择一条记录"); } }else{ form1.method.value = method; form1.submit(); } }3:form这样写:<form method = "post" name = "form1" action = "/fetchReceiptsAction.do" > <input type = 'hidden' name = 'method' > 从界面(a),使用dispatch(b),转发到另外一个action(c)之后,那么(c)能得到(a)的表单吗? 如果像下面这样行吗?他是怎么得到值的呢?<html:form action="/ChoiceAction"> <TABLE border="0" width="100%"> <TR> <TD align="right"> <html:submit property="method"> <bean:message key="button.pathone"/> </html:submit> </TD> <TD align="right"> <html:submit property="method"> <bean:message key="button.pathtwo"/> </html:submit> </TD> <TD align="right"> <html:submit property="method"> <bean:message key="button.paththree"/> </html:submit> </TD> </TR> </TABLE></html:form>public class ChoiceAction extends LookupDispatchAction { // --------------------------------------------------------- Instance Variables // --------------------------------------------------------- Methods public ActionForward path_one(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return (mapping.findForward("choice_one")); } public ActionForward path_two(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return (mapping.findForward("choice_two")); } public ActionForward path_three(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { return (mapping.findForward("choice_three")); } protected Map getKeyMethodMap() { Map map = new HashMap(); map.put("button.pathone", "path_one"); map.put("button.pathtwo", "path_two"); map.put("button.paththree", "path_three"); return(map); }} 不管你用多少个form,显然,一次只能提交一个表单,如果没有为name属性指定值,它将通过使用action 属性值查询相应的actionMapping 元素来计算,在这里表单bean名被确定。换句话说,如果没有为form标记指定name属性,标记符将使用配置文件的action元素中name属性值。这点非常重要。 oracle sql 问题 jsp页面的小问题 手机上传图片的问题。 webservices weblogic 客户端 请求 https 服务 问题。 struts.xml所遇到的问题请教 J2EE应用程序中的纵向和横向如何理解? 发邮件出错,没人知道什么原因?发帖子没人理? 高分请教达内的J2EE培训教学质量 50分问下个开发工具的问题。大家帮我看下吧,麻烦了! JMS Server 各位高手帮帮忙!请教关于JAVAMAIL的问题(急!在线等) 配置数据源之后,tomcat无法启动
<tr>
<td colspan = "14" align = "right" >
<input name = "Button2" type = "button" class = "ListButton" onClick = "set('add')" value = "新增">
<input name = "Button2" type = "button" class = "ListButton" onClick = "set('modify')" value = "修改">
<input name = "Button2" type = "button" class = "ListButton" onClick = "set('delete')" value = "删除">
</td>
</tr>2:javascript
function set(method){
if(method == 'modify'||method == 'delete'){
if(validate()){
form1.method.value = method;
form1.submit();
}else{
alert("至少选择一条记录");
}
}else{
form1.method.value = method;
form1.submit();
}
}3:form这样写:
<form method = "post" name = "form1" action = "/fetchReceiptsAction.do" >
<input type = 'hidden' name = 'method' >
<html:form action="/ChoiceAction">
<TABLE border="0" width="100%">
<TR>
<TD align="right">
<html:submit property="method">
<bean:message key="button.pathone"/>
</html:submit>
</TD>
<TD align="right">
<html:submit property="method">
<bean:message key="button.pathtwo"/>
</html:submit>
</TD>
<TD align="right">
<html:submit property="method">
<bean:message key="button.paththree"/>
</html:submit>
</TD>
</TR>
</TABLE>
</html:form>
public class ChoiceAction extends LookupDispatchAction { // --------------------------------------------------------- Instance Variables // --------------------------------------------------------- Methods public ActionForward path_one(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{ return (mapping.findForward("choice_one"));
} public ActionForward path_two(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{ return (mapping.findForward("choice_two"));
} public ActionForward path_three(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{ return (mapping.findForward("choice_three"));
}
protected Map getKeyMethodMap()
{
Map map = new HashMap();
map.put("button.pathone", "path_one");
map.put("button.pathtwo", "path_two");
map.put("button.paththree", "path_three");
return(map);
}}