静态页面:
</head>
<body>
<form action="ShowAirline.jsp" method="get">
出发城市<input type="text" name=Departure/><br>
目的城市<input type="text" name=Destination/><br>
出发日期<input type="text" name=Date/><br>
<input type="button" name=submit value=查询 />
</form>
</body>
</html>JSP页面:
<%@page language="java" contentType="text/html charset=utf-8" pageEncoding="utf-8"%>
<%@page import="java.util.LinkedList"%>
<%@page import="Service.ShowAirline"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>查询结果<title>
</head>
<body>
<%
String Departure = request.getParameter("Departure");
String Destination = request.getParameter("Destination");
String departureDate = request.getParameter("Date");
if(Departure == null){
Departure = "";
}
if(Destination == null){
Destination = "";
}
if(departureDate == null){
departureDate = "";
}

ShowAirline show = new ShowAirline();
LinkedList Airline_info = show.Search();
int i = 0;
int sum = Airline_info.size();
String info[] = new String[sum];
while(i < sum){
info[i] = (String)Airline_info.get(i);
i++;
}
for(i = 0; i < sum; i++){
String each_info[] = info[i].split("|");
%>
<table border="" align="center">
<tr>
<td>航班</td><td>出发地</td><td>目的地</td><td>出发日期</td><td>票数</td><td>价格</td>
</tr>
<br>
<%
if(each_info[1]==Departure && each_info[2]==Destination && each_info[3]==departureDate){

%>
<tr>
<td><%=each_info[0]%></td>
<td><%=each_info[1]%></td>
<td><%=each_info[2]%></td>
<td><%=each_info[3]%></td>
<td><%=each_info[4]%></td>
<td><%=each_info[5]%></td>
</tr>
<br>
</table>
<%
}
}
%>

<form action="Serice.purchase" method="get">
请输入航班号<input type="text" name=id/><br>
请输入购买票数<input type="text" name=number/><br>
<input type="button" name=submit/>
</form>
</body>
</html>

解决方案 »

  1.   

    静态页面中的<input type="button" name=submit value=查询 />改为<input type="submit" name="submit" value=查询 />试试。如果type是button,则这只是一个按钮,需要将type改为submit才是提交
      

  2.   

    一楼正解
    <input type="button" name=submit value=查询 />
    只是一个按钮,而要提交表单就要使用type="submit"的按钮
    不过如果用button你可以通过JS提交,呵呵!
      

  3.   

    这里改过来了,但是出现了新问题,request.getParameter()总是返回null
      

  4.   

    你的表单提交方式是get,用request.getParameter()取不到值的
    对于get方式,服务器端用Request.QueryString获取变量的值
    建议改为post方式提交
      

  5.   


    <form action="ShowAirline.jsp" method="get">这个地方的method="get"改成method="post"试试。
    另外还有一个地方千万要注意,就是java的变量定义出发城市<input type="text" name=Departure/><br>
    目的城市<input type="text" name=Destination/><br>
    出发日期<input type="text" name=Date/><br>把“name=Departure”改成"name=departure",java中变量定义第一个英文单词的字符小写,跟这个可能有关系;
    楼主改过来试试