JSP提交到Servlet出现405错误

这是错误信息typeStatusreportmessageHTTPmethodPOSTisnotsupportedbythisURLdescriptionThespeci... 这是错误信息type Status report

message HTTP method POST is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method POST is not supported by this URL).

============================================================================================================

这是JSP页面
<center>
<form action="./servlet/addImages" method="post" enctype="multipart/form-data">
<table width="900" cellspacing="1" bgcolor="#999999">
<tr>
<td height="50" colspan="2" align="center" bgcolor="#FFFFFF">图片添加 </td>
</tr>

<tr>
<td width="200" height="30" bgcolor="#FFFFFF" align="center">图片名称 </td>
<td width="700" bgcolor="#FFFFFF"> <input name="name" type="text" size="50"> </td>
</tr>
<tr>
<td height="30" align="center" bgcolor="#FFFFFF">添加图片 </td>
<td bgcolor="#FFFFFF"> <input name="pic" type="file" size="50"> </td>
</tr>
<tr>
<td height="20" colspan="2" align="center" bgcolor="#FFFFFF">
<input type="submit" value="提交">

<input type="reset" value="重置">
</td>
</tr>
</table> </form>
</center>
============================================================================
下面是Servlet代码

package org.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

import org.lxh.smart.SmartUpload;

public class addImages extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response, PageContext pageContext)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @param pageContext
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response, PageContext pageContext)
throws ServletException, IOException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
SmartUpload smartupload = new SmartUpload();
smartupload.initialize(pageContext);
try {
smartupload.upload();
smartupload.save("upload");
} catch (Exception e) {
// TODO: handle exception
}
}

}
展开
 我来答
百度网友ef12bc8dc
推荐于2017-11-22
知道答主
回答量:5
采纳率:0%
帮助的人:11.4万
展开全部
估计你servlet路径错了~! ,还有一种碧谈可能是你的服务期不允扮友许post方式提交,你可以用get提交~!悔缺碰
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式