HTTP method GET is not supported by this URL

本文解决了一个特定的问题:当使用浏览器访问本地服务器上的特定URL时,出现HTTP方法GET不被支持的错误。问题的原因在于Web.xml配置文件中指定的URL模式与servlet中实现的方法不匹配。servlet中实现了POST方法而非GET方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


浏览器中输入: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()方法即可

转载于:https://www.cnblogs.com/abracadabra233/p/10593276.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值