Servlet读取表单提交数据
getParameter(请查Servlet的帮助文档)
public java.lang.StringgetParameter(java.lang.String name)
Returns the value of a request parameter as aString, ornullif the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
步骤1、编写含登录表单的jsp页面
(1)注意要改变页面的编码方式为支持中文的编码方式
默认的编码方式为iso8859-1,需要修改为gb2312或utf-8,推荐为utf-8
(2)编写登陆的form表单
注意表单元素的name属性,将来用于Servlet获取表单值的方法中
name: | |
pass: |
步骤2、编写Servlet去读取表单的数据、并在web.xml中配置
(1)servlet的编写protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("doGet&