为什么有的servlet找不到?
我写了个上传文件的servlet,命名为MultipartTestServlet.java
MultipartTestServlet.class放在..\webapps\ROOT\WEB-INF\classes\test下
在web.xml中也添了
<servlet>
<servlet-name> MultipartTestServlet </servlet-name>
<servlet-class> test.MultipartTestServlet </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> MultipartTestServlet </servlet-name>
<url-pattern> /MultipartTestServlet </url-pattern>
</servlet-mapping>
上传页面Upload.html放在..\webapps\ROOT下
Upload.html内容如下:
<html>
<body leftmargin= "0 " marginwidth= "0 " marginheight= "0 ">
<center>
<form name= "form1 " method= "POST " action= "MultipartTestServlet " ENCTYPE= "multipart/form-data ">
<table width= "345 " border= "0 " align= "left " cellpadding= "0 " cellspacing= "0 " >
<tr> <td height= "21 " colspan= "2 ">
<div align= "left ">
<input name= "file1 " size= "30 " type= "file ">
</div> </td>
<td width= "12% " align= "right ">
<div align= "left ">
<input name= "upload " type= "submit " value= "上传 "/>
</div> </td> </tr>
</table>
</form>
</center>
</body>
</html>
为什么运行时就是找不到这个servlet?
------解决方案--------------------在JSP上加上getContextPath()试试
------解决方案--------------------你运行的时候看看地址栏的url,当你要访问这个servlet的时候是不是跳到了别的webapp下。
------解决方案--------------------action= " <%=request.getContextPath()%> /MultipartTestServlet "