
大体流程:
首先jsp前台页面提交数据到后台-->后台取到前台提交上来的数据-->将取到的数据放到域里面,方便使用的时候取。
相关代码:
// 得到request,用来 *** 作数据
>
送你一个 抽取百度首页 import javaioByteArrayOutputStream; import java1、动态ActionForm 动态ActionForm是为了避免标准ActionForm膨胀而设计的,使用
第一个页面:
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@page import="orgaccps2DaoStationDao"%>
<%@page import="javautilList"%>
<%@page import="orgaccps2entityStation"%>
<html>
<head>
</head>
<body>
<form action="pricejsp" method="post" name="myform">
<h2>查询结果:</h2>
<table border="1">
<tr>
<td>车次</td>
<td>始发地</td>
<td>目的地</td>
<td>硬座价格</td>
</tr>
<%
requestsetCharacterEncoding("gbk");
String num=requestgetParameter("stationNum");
String outstation=requestgetParameter("outcity");
String arrivestation=requestgetParameter("arrivecity");
StationDao sd=new StationDao();
List<Station>list=sdgetstation(num,outstation);
List<Station>list2=sdgetstation(num,arrivestation);
float price1=0;
float price2=0;
float price=0;
for(Station st:list)
{
price1=stgetSitePrice();
}
for(Station sn:list2)
{
price2=sngetSitePrice();
}
price=price1-price2;
%>
<tr>
<td><%=num %></td>
<td><%=outstation%></td>
<td><%=arrivestation %></td>
<td><%=price %></td>
</tr>
</table>
</form>
</body>
</html>
如果是FROM提交过来的。那么使用 RequestForm("字段名称")
如果是GET提交过来的。那么使用 RequestQueryString("字段名称")
如果不需要区分或你搞不清楚的话,那么使用 Request("字段名称")
表单是用form来填写,在提交前可以获取表单里面的数据。我这里用jquery实现。
<html><body>
<form method='post' action=''>
<label for='inputText'>inputText</label>
<input type='text' id='inputText'/>
<br/>
<label for='checkBox1'>checkBox1</label>
<input type='checkbox' id='checkBox1'/>
<br/>
<label for='checkBox2'>checkBox2</label>
<input type='checkbox' id='checkBox2'/>
<!--其他你想填写的表单选项-->
<input type='button' value='提交表单' id='submitBtn'/>
</form>
<script>
$(document)ready(function()
{
$('#submitBtn')click(function(e)
{
/一系列根据自己的意图判断输入框是否已输入内容并决定是否往下执行/
//获取表单的系列化数据。这会生成一个A=valueA&B=valueB这种形式的字符串。
var formData = $('form')serialize();
$post('目标地址',formData,成功/失败回调函数);
epreventDefault();
});
});
</script>
</body>
</html>
<script type="text/javascript">
// 获取指定form中的所有的<input><select>对象
function getElements(formId) {
var form = documentgetElementById(formId);
if(form == null){
return false;
}
var elements = new Array();
var inputTagElements = formgetElementsByTagName('input');
for (var j = 0; j < inputTagElementslength; j++) {
elementspush(inputTagElements[j]);
}
var selectTagElements = formgetElementsByTagName('select');
for (var j = 0; j < selectTagElementslength; j++) {
elementspush(selectTagElements[j]);
}
return elements;
}
扩展资料:
form表单提交
在form标签中添加Action(提交的地址)和method(post),且有一个submit按钮。
(<input type='submit'>)就可以进行数据的提交,每一个input标签都需要有一个name属性,才能进行提交。
当点击登陆时,向数据库发生的数据是:username=username&password=password
这种默认的提交方式,一般会进行页面的跳转(不成功时跳转到当前页面)。而有时候是对d出框进行数据提交的,希望提交成功则关闭d出框并刷选父页面,失败则提示失败原因,且d出框不关闭。此时可以采用Ajax进行数据提交。
以上就是关于如何通过submit提交form表单获取后台传来的返回值全部的内容,包括:如何通过submit提交form表单获取后台传来的返回值、获取表单form提交的参数,通常使用的内部对象是哪两个方法、如何利用request对象取得表单中的数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)