簡體   English   中英

Servlet異常調用

[英]Servlet abnormal invoking

我有一個servlet:

@WebServlet ("/*")
public class X extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
    throws ServletException, IOException {
        System.out.println("1");
    }
}

我不知道為什么它兩次打印“ 1”。 誰能解釋?

輸出:
1
1

你可以打印出來

request.getRequestURI() 

確認兩個請求的網址。

瀏覽器發送2個請求。 1是您的GET請求,而第二個則是嘗試檢索收藏夾圖標。

可能是因為您的servlet注釋。 @WebServlet ("/*")嘗試使用此@WebServlet( displayName="Notification Servlet", urlPatterns = {"/yourservletpath"})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM