瀏覽器中輸入: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()方法即可