我有一个WebFilter,它充当所有 JSP 页面的过滤器:
"*.jsp"
.
如何测试请求是对 JSP 过滤器的 GET 还是 POST?
您可以像这样检查您的过滤器:
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");
}