Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if HTTP request is GET or POST in Struts 2 action?

Is there a way to know in Struts2 action's method if this is GET or POST request?

like image 902
Aleksey Otrubennikov Avatar asked May 28 '10 09:05

Aleksey Otrubennikov


1 Answers

Your action should implent org.apache.struts2.interceptor.ServletRequestAware, so your action class should have something like

private HttpServletRequest httpRequest;
// ...
public void setServletRequest(HttpServletRequest request) {    
  this.httpRequest = request;
 }

Then just do:

 String method = httpRequest.getMethod() ;
like image 73
user454322 Avatar answered Oct 22 '22 19:10

user454322