新人求助,get提交服务器能接收数据,post提交的时候服务器就没反应了
用的表单提交数据,表单的html代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<form action="/Myday06/servlet/RequestDemo05" method="post">
用户名:
<input type="text" name="username"/>
<br />
密码:
<input type="password" name="password" />
<br />
性别:
<input type="radio" name="sex" value="male" />男
<input type="radio" name="sex" value="female" />女
<br />
城市:
<select name="city">
<option value="bj">北京</option>
<option value="sh">上海</option>
<option value="gz">广州</option>
</select>
<br />
爱好:
<input type="checkbox" name="habit" value="basketball"/>篮球
<input type="checkbox" name="habit" value="football" />足球
<input type="checkbox" name="habit" value="swim "/>游泳
<input type="checkbox" name="habit" value="run" />跑步
<br />
简历:<textarea rows="5" cols="60" name="resume"></textarea><br/>
<input type="submit" value="提交" />
</form>
</body>
</html>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username") ;
System.out.println("username="+username);
String password = request.getParameter("password") ;
System.out.println("password="+password);
String sex = request.getParameter("sex") ;
System.out.println("sex="+sex);
String city = request.getParameter("city") ;
System.out.println("city="+city);
String habits[] = request.getParameterValues("habit") ;
for(int i=0;habits!=null&&i<habits.length ;i++){
System.out.println("habit="+habits[i]);
}
}