request--各种表单输入项数据的获取学习笔记
html
index.html
成都创新互联于2013年成立,是专业互联网技术服务公司,拥有项目网站设计制作、成都网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元木垒哈萨克做网站,已为上家服务,为木垒哈萨克各地企业和个人服务,联系电话:18980820575
java
package cn.web.request;
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 Rdome5 extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
//将[请求体]的中文以UTF-8方式重新编码
request.setCharacterEncoding("UTF-8");
///this.getServletContext().getRequestDispatcher("/download.html").forward(request, response);
String username = request.getParameter("username");
String password = request.getParameter("password");
String gender = request.getParameter("gender");
String[] likes = request.getParameterValues("likes");
String upfile = request.getParameter("upfile");
String city = request.getParameter("city");
String message = request.getParameter("message");
String id = request.getParameter("id");
//控制台输出
System.out.println("username="+username);
System.out.println("password="+password);
System.out.println("gender="+gender);
System.out.println("likes="+likes.length);
System.out.println("upfile="+upfile);
System.out.println("city="+city);
System.out.println("message="+message);
System.out.println("id="+id);
}
}
结果:
username=234324
password=234
gender=male
likes=1
upfile=
city=bj
message=23432
id=20111008
username=234324
password=234
gender=male
likes=1
upfile=
city=bj
message=23432
id=20111008
本文题目:request--各种表单输入项数据的获取学习笔记
链接URL:http://ybzwz.com/article/jccejg.html