表单提交到servlet 然后将表单结果写回html文件??
在lomboz-Eclipse建项目Servlet
然后webcontent下建一JSP文件用表单定位到Servlet1
<form name= "form1 " method= "post " action= "/Servlet1 ">
JSP文件位于:
E:\JavaProject\Servlet\WebContent\test.html
Servlet1位于:
E:\JavaProject\Servlet\WebContent\WEB-INF\Servlets\Servlet1.class
web.xml设置如下:
Servlet </display-name>
<servlet>
<description>
</description>
<display-name>
Servlet1 </display-name>
<servlet-name> Servlet1 </servlet-name>
<servlet-class>
Servlet1 </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> Servlet1 </servlet-name>
<url-pattern> /Servlet1 </url-pattern>
</servlet-mapping>
系统老提示:
type Status report
message /servlet/Servlet1
description The requested resource (/servlet/Servlet1) is not available.
--------------------------------------------
Apache Tomcat/5.5.25
------解决方案--------------------
类要放在WEB-INF/classes下面~
------解决方案--------------------
<form name= "form1 " method= "post " action= "/Servlet1 "> 是对的,你改了反而会找不到servlet
看看你的错误提示,description The requested resource (/servlet/Servlet1) is not available.你请求的servlet路径和你servlet的放置路径不同吧,最好能把你的servlet代码帖出来.
------解决方案--------------------
Servlet1位于:
改成
E:\JavaProject\Servlet\WebContent\WEB-INF\classes\Servlet1.class
不要有servlets目录
------解决方案--------------------
<servlet-class> Servlet1 </servlet-class>
你的java文件没有包吗?有的话应该是 packagename.Servlet1