HTTP method GET is not supported by this URL


浏览器中输入:http://localhost:8080/项目名/bookquery 后报错;

错误:

Type Status Report

Message HTTP method GET is not supported by this URL

Description The method received in the request-line is known by the origin server but not supported by the target resource.

Web.xml片段:

<servlet>
<servlet-name>bookQuery</servlet-name>
<servlet-class>action.BookQueryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>bookQuery</servlet-name>
<url-pattern>/bookquery</url-pattern>
</servlet-mapping>
原因:
浏览器输入链接请求是doget()方式,而我在servlet里重写的是dopost方法.
改为上一层的service()方法即可

posted @ 2019-03-25 13:41  abracadabra233  阅读(1394)  评论(0编辑  收藏  举报