我有一个 WebFilter ,它充当所有JSP页面的过滤器:
"*.jsp"
。
如何测试请求是否为JSP过滤器的GET或POST?
答案 0 :(得分: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");
}