我用Eclipse开发了个Web应用. 遇到个问题.
我在WebSMS项目的Src下有com/servlet/Enter.java这个servlet.
在Webroot/login/enter.jsp, 里有
" <FORM name=reg_frm action= "/Enter " method= "POST "> "的代码
运行后, 出现 "HTTP Status 404 - /Enter "的错误信息. 地址栏是 "http://localhost:8080/Enter ", 请问这是怎么回事?
是路径不对 应该如何写.在Web.xml里是
<servlet>
<servlet-name> Enter < rvlet-name>
<servlet-class> com.servlet.Enter < rvlet-class>
< rvlet>
<servlet-mapping>
<servlet-name> Enter < servlet-name>
<url-pattern> /Enter </url-pattern>
< servlet-mapping>
请各位大侠帮个忙了.不胜感激了.
------解决方案--------------------
" <FORM name=reg_frm action= "/Enter " method= "POST "> "
改为:
" <FORM name=reg_frm action= "/WebSMS/Enter " method= "POST "> "
------解决方案--------------------
" <FORM name=reg_frm action= "Enter " method= "POST "> "
不要设到根路径下这样应该可以了
------解决方案--------------------
<%String url=request.getContextPath();%>
<FORM name=reg_frm action= " ' <%= url%> /Enter " method= "POST ">
------解决方案--------------------
eagleking012((菜鸟也疯狂))的回答正解