如何利用request对象取得表单中的数据

如何利用request对象取得表单中的数据,第1张

第一个页面:

<%@ 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>

直接代码仅供参考:

private void showParams(>

string str=thisRequest["id"]ToString();这句话是错误的,

应该是:

string str=ResquestQueryString["id"];

给个建议,最还不要用strTostring();如果str不为null的话,这样写实可以的,但是如果str==null得话,这样是不可以的,因为null是没有被分配空间的,最好使用ConvertToString(str);

以上就是关于如何利用request对象取得表单中的数据全部的内容,包括:如何利用request对象取得表单中的数据、如何利用ASP的REQUEST对象取得表单中的数据、如何遍历HttpServletRequest获取请求参数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

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

原文地址: https://www.outofmemory.cn/web/9269005.html

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

发表评论

登录后才能评论

评论列表(0条)

保存