我用dreamweave写了一个login.htm文件内容如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<p>请输入用户名和密码:</p>
<form id="form1" name="form1" method="post" action="web2/servlet/login">
  <table width="276" border="0">
    <tr>
      <td width="80">用户名:</td>
      <td width="186"><label for="username"></label>
      <input name="username" type="text" id="username" size="18" maxlength="10" /></td>
    </tr>
    <tr>
      <td>密码:</td>
      <td><label for="password"></label>
      <input name="password" type="password" id="password" size="18" maxlength="10" /></td>
    </tr>
    <tr>
      <td><input type="submit" name="submit" id="submit" value="提交" /></td>
      <td><input type="reset" name="reset" id="reset" value="重置" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>写完后将login.htm文件另存为自己在myeclipse中的web2/webroot根目录下,然后从web2中新建一个servlet只重写post方法
启动tomcat,也配置文件了,在浏览器运行时输入http://localhost:8088/web2/servlet/login.html,提示HTTP Status 405 - HTTP method GET is not supported by this URL急求大家帮忙

解决方案 »

  1.   

    get方法改 一下  doPost(request,response);就可以了
      

  2.   

    我看的教学视频上完全是按我做的方法做的,他就可以我就不行了。他新建servlet时没有重写doGet方法,要是按照你这样改的话可以解决问题,但是我写的login.htm好像就没有作用了。
    我不明白自己编写的htm文件是怎么和servlet联系在一块的。。求指教
      

  3.   


    <form id="form1" name="form1" method="post" action="web2/servlet/login">这句就是联系servlet的,method是定义传递方式,你这里是post,action就是你要传递到的servlet,最好是每次都重写方法,这样才不会出现一些其实没必要的错误
      

  4.   

    你的form表单中的action属性,将你的html和servlet联系在一起了,你的路径就不对,访问html的路径是http://localhost:8080/web2/login.html,同时你需要修改配置文件,让你的action能够找到servlet
      

  5.   

    与当你的参数涉及到uri的时候用get方法,这个post就可以的
      

  6.   

    没有作用的原因,可能是你的action有问题吧,你仔细检查下,servlet也不是这么写的吧
      

  7.   


    好久没用过servlet了  ,应该去配置一下web.xml,你可以去看看,web.xml<servlet-mapping> 
    <servlet-name>login</servlet-name> 
    <url-pattern>/login</url-pattern> 
    </servlet-mapping> 
      

  8.   

    name,不知道你的路径是什么,一般都是相对路径
      

  9.   

    楼主的html文件中的action路径不对,不需要web2
      

  10.   

    谢谢各位帮忙,我在最后浏览器里输入的不对,把servlet去掉就对了。
      

  11.   

    你的servlet写在那个文件夹下,如果你的servlet。java写在servlet文件夹下,你的action可以这样写action="login"web.xml你可以这样配置<servlet><servlet-name>login</servlet-name><servlet-class>servlet/servlet.java</servlet-class><servlet-mapping><servlet-name>login</><url-pattern>/login</>就可以的