0

我有一个WebFilter,它充当所有 JSP 页面的过滤器:

"*.jsp".

如何测试请求是对 JSP 过滤器的 GET 还是 POST?

4

1 回答 1

2

您可以像这样检查您的过滤器:

       HttpServletRequest httpRequest = (HttpServletRequest) request;        
       if(httpRequest.getMethod().equalsIgnoreCase("POST")){
           System.out.println("This is a POST request");
       } else if (httpRequest.getMethod().equalsIgnoreCase("GET")) {
           System.out.println("This is a GET request");
       }
于 2013-06-08T16:17:07.403 回答