急急急急急急! 大神 !大神!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>register.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="/myday07/Demo6" method="post">
<table align="center" border="1">
<caption>用户注册</caption>
<tr><th>用户名</th><td><input type="text" name="username" /></td></tr>
<tr><th>密码</th><td><input type="text" name="password" /></td></tr>
<th>性别<td>
<input type="radio" name="gender" value="male" checked="checked" />男
<input type="radio" name="gender" value="female" />女</td></th>
<tr><th>爱好</th><td>
<input type="checkbox" name="likes" value="singer" />唱歌
<input type="checkbox" name="likse" value="java" />爪哇
<input type="checkbox" name="likes" value="ios" />苹果系统</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="提交" />   <input type="reset" value="重写" /></td></tr></table>
</form>
</body>
</html>
[color=#FF0000]上面写得是一个register.html,用来填写后提交到"/myday07/Demo6" method="post"表单提交。
接下来我又写了Demo6:[/color]
package cn.itcast.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 Demo6 extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String gender = request.getParameter("gender");
String[] likes = request.getParameterValues("likes");
System.out.println("username:" + username);
System.out.println("password:" + password);
System.out.println("gender:" + gender);
System.out.println("likes:" + likes);
}
}
tomcat部署后我访问register.html 填写成功后我点提交按钮,出来这个
HTTP Status 405 - HTTP method GET is not supported by this URL
--------------------------------------------------------------------------------
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
求大神指教:我把代码发给别人,别人可以正常运行,我的机子上不行。急急急! 在线等!雪地里跪求
------解决方案--------------------
下面你重写doget方法没有
------解决方案--------------------
get提交方式,但没有重写doGet方法,重写doGet方法
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);
}
------解决方案--------------------
是get
[code=java]
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doPost(req, res);
}
------解决方案--------------------