日期:2014-05-19 浏览次数:20733 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >
<head></head>
<body>
<form id = "form1" name = "form1" method = "post" action ="servlet/ThreeParams">
<table width = "234" border = "2">
<tr>
<td width = "90">param1</td>
<td width = "90"><input name = "param1" type = "text" id="param1" /> </td>
</tr>
<tr>
<td width = "90">param2</td>
<td width = "90"><input name = "param2" type = "text" id="param2" /> </td>
</tr>
<tr>
<td width = "90">param3</td>
<td width = "90"><input name = "param3" type = "text" id="param3" /> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" value="提交">
</label></td>
</tr>
</table>
</form>
</body>
</html>
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ThreeParams extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter pw = resp.getWriter();
resp.setContentType("text/html");
pw.println(req.getParameter("param1"));
pw.println("<br/>");
pw.println(req.getParameter("param2"));
pw.println("<br/>");
pw.println(req.getParameter("param3"));
pw.println("<br/>");
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doGet(req,resp);
}
}