struts2中怎样实现一个表单两个action
时间:2011-09-17
来源:互联网
//form表单
<form id="form2" name="form2" action="">
<tr>
<td
<center>
<input name="addButton" type="submit" value="添加" />
<input name="refreshButton" type="submit" value="更新" />
</center>
</td>
</tr>
</table>
</form>
//struts.xml
<package name="1" extends="struts-default">
<action name="search" class="rtcrud.SearchInfo">
<result name="success">/showInfo.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
作者: qiuqiang19880520 发布时间: 2011-09-17
作者: ywvision 发布时间: 2011-09-17
<input name="refreshButton" type="submit" value="更新" onlick="document.form2.action='url2';submit()"/>
思路这样的,点button时动态改变form的action值
作者: zyz1985 发布时间: 2011-09-17
你不能把添加和更新从前端传参数至后台,action根据判断去执行(具体是添加还是更新)?
一般传什么值?可以直接传那个value吗?
若是的话后台应该怎么获取这个值呢?是不是和一般action的属性获取方法一样呢,只需设置set和get方法吗?
作者: qiuqiang19880520 发布时间: 2011-09-17
<form action="baocun.action" method="post">
<input type="submit" value="添加"/>
</form>
<hr>
<b>用户密码修改:</b><br>
<form action="xiugai.action" method="post">
<input type="submit" value="更新">
</form>
struts.xml:
<action name="baocun" class="com.wiew.UserView" method="execute1">
<result name="no">
<param name="location">/index.jsp</param>
</result>
</action>
<action name="xiugai" class="com.wiew.UserView" method="execute2">
<result name="no">
<param name="location">/index.jsp</param>
</result>
</action>
execute1方法和execute2方法分别实现添加和更新功能!
作者: dxndsc 发布时间: 2011-09-17
表单:
<form action="baocun.action" method="post">
<input type="submit" value="添加"/>
</form>
<hr>
<b>用户密码修改:</b><br>
<form action="xiugai.action" method="post">
<input type="submit" v……
大哥..能不能写在一个表单里呢?我看你是分了俩表单啊
作者: qiuqiang19880520 发布时间: 2011-09-17
var formAction = document.forms['form2'].action; document.forms['form2'].action = ....;
作者: canghaiguzhou 发布时间: 2011-09-17
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28