request对象和response对象(10)
来源:未知 责任编辑:责任编辑 发表时间:2014-05-10 12:18 点击:次
p> 城市<input type="text" name="city" /><br/>
p> <input type="submit" value="提交">
p> </form>
p> </body>
p></html>
p>复制代码
p>复制代码
p>package cn.lsl.request;
p>
p>import java.io.IOException;
p>import java.io.PrintWriter;
p>import javax.servlet.ServletException;
p>import javax.servlet.http.HttpServlet;
p>import javax.servlet.http.HttpServletRequest;
p>import javax.servlet.http.HttpServletResponse;
p>
p>public class RequestDemo4 extends HttpServlet {
p>
p> public void doGet(HttpServletRequest request, HttpServletResponse response)
p> throws ServletException, IOException {
p> String name = request.getParameter("name");
p> System.out.println(name);
p> String city = request.getParameter("city");
p> System.out.println(city);
p> }
p>
p> public void doPost(HttpServletRequest request, HttpServletResponse response)
p> throws ServletException, IOException {
p> doGet(request,response);
p> }
p>}
p>复制代码
p>5.获取复杂表单的数据及解决中文乱码问题
p>
p>regist.html
p>
p>复制代码
p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
p><html>
p> <head>
p> <title>regist.html</title>
p> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
p> <meta http-equiv="description" content="this is my page">
p> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
p> </head>
p>
p> <body>
p> <form action="/Request/servlet/RequestDemo5" method="post">
p> <table>
p> <tr>
p> <td>
p> 用户名
p> </td>
p> <td>
p> <input type="text" name="username" />
p> </td>
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>