本人是新手来的。。刚学JSP
情况是这样的,我想把表单的内容传给servlet,每次提交的时候都404错误,以下是错误信息HTTP Status 404 - /UserLogin--------------------------------------------------------------------------------type Status reportmessage /UserLogindescription The requested resource (/UserLogin) is not available.
------------------------------------------------------------------------------------我是这样写的 <form action ="/UserLogin" method="post">
------------------------------------------------------
web.xml部署
<display-name>UserLogin</display-name>
<servlet-name>UserLogin</servlet-name>
<servlet-class>jsp_servlet_javabean.UserLogin</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserLogin</servlet-name>
<url-pattern>/UserLogin</url-pattern>
</servlet-mapping>
-----------------------------------------------------
提交前地址:
http://localhost:8080/test/JSP_Servlet_JavaBean/login.jsp
提交后地址:
http://localhost:8080/UserLogin究竟是哪里出问题了~各位大大们求助。

解决方案 »

  1.   

    你把 action和Xml里面的"/"去掉再试试
      

  2.   

    web.xml <servlet-mapping>
    <servlet-name>UserLogin</servlet-name>
    <url-pattern>/UserLogin.do</url-pattern>
    </servlet-mapping>页面:
    <form action ="UserLogin.do" method="post">
      

  3.   

     <form action ="UserLogin" method="post">
      

  4.   


    上面几楼的意思都是把action里的“/”取出掉,但去除了“/”后还是有问题
    -----------------------------------------------------------------HTTP Status 404 - /test/JSP_Servlet_JavaBean/UserLogin--------------------------------------------------------------------------------type Status reportmessage /test/JSP_Servlet_JavaBean/UserLogindescription The requested resource (/test/JSP_Servlet_JavaBean/UserLogin) is not available.----------------------------------------------------------------------------------提交前地址为:
    http://localhost:8080/test/JSP_Servlet_JavaBean/login.jsp
    去掉action的"/"后提交后地址为:
    http://localhost:8080/test/JSP_Servlet_JavaBean/UserLoginUserLogin.java在电脑上的路径是:
    E:\学习\JAVA\apache-tomcat-6.0.33\apache-tomcat-6.0.33\webapps\J2EETEST\test1\src\jsp_servlet_javabean
    login.jsp在电脑上的路径是:
    E:\学习\JAVA\apache-tomcat-6.0.33\apache-tomcat-6.0.33\webapps\J2EETEST\test1\WebBoot\JSP_Servlet_JavaBean求助啊感觉是路径不对的
      

  5.   

    把Web应用的ContextPath给漏了,提交后的路径应该是:http://localhost:8080/test/UserLogin<form action ="UserLogin" method="post">修改为<form action ="/test/UserLogin" method="post">或者用 <%=request.getContextPath()%> 自动获取 Web应用的contextpath该帖子我从新发了一次,终于有个大神帮手解决了,上面的就是方法,其实估计也是简单的问题,只是对于我这些初学者不会解决