在一个jsp页面上如何存在多个from表单。

在一个jsp页面上如何存在多个from表单。,第1张

可以直接创建多个form即可,形式就是“<form></form><form></form>”,此时每个form中的内容就是独立提交的部分。

举例:

<form id='modify1' name="modify1" method="post" enctype="multipart/form-data" action="${ctx}/report/rate_exchange.jsp" >

<table class="table_common" id="table1" cellspacing="1" cellpadding="0">

<tr class='title_tr' >

<td style="white-space: nowraptext-align: center" colspan="4">

<input type="file" name="fileName" id="filePath">

<input type="button" style="white-space: nowraptext-align: center" class="List_Button2" value="<BOC:I18N name="submit"/>" onclick="submitForm1()" />

<input type="reset" style="white-space: nowraptext-align: center" class="List_Button2" value="<BOC:I18N name="reset"/>" onclick='confirm("你确认要取消本次上传吗?")'/>

</td>

</tr>

</table>

</form>

<!-- end 文件上传-->

<form>

<table>

<tr class="title_tr" >

<TH width="10%" style="white-space: nowraptext-align: centercolor: red"><%=worry %></TH>

</tr>

<tr class="title_tr" >

<TH width="10%" style="white-space: nowraptext-align: centercolor: green"><SPAN><%=right %></SPAN></TH>

</tr>

</table>

</form>

<HTML>

<HEAD>

</HEAD>

<script>

function addForm(){

var form = document.createElement("form")

var str= "<input name="up" type='file'/>"//这里放你想在form里放的标签。

form.innerHTML = str

document.body.appendChild(form)

}

</script>

<BODY>

<input type="button" onclick="addForm()" value="点击添加"/>

</BODY>

</HTML>

1、form表单中有action属性,或者是包含input,这个input的name是action,value是对应的同名action类。

2、表单submit的时候,通过HttpServletRequestrequest.getParameter(‘name属性’)方法得到form的数据

3、数据上传多个form的时候,启动的是web/screen中同名的java类,和对应的vm一起完成页面的加载,同时也会填充context。

4、最后,action类将数据传入数据库。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11944647.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存