1

in my application I send all forms as POST request :

<s:form method="POST">

however I noticed when I prepare GET call like this:

www.domain.com?method:Save&param1=aa

proper action is invoked.

My question: is it possible to prevent GET calls for particular actions ?

So if I run www.domain.com?method:Save&param1=aa , action "Save" would not be invoked?

Roman C
  • 49,761
  • 33
  • 66
  • 176
lucas999
  • 169
  • 1
  • 2
  • 11
  • why you are practising with such outdated heavy weight frameworks? use Spring instead! – ArifMustafa Jan 05 '18 at 15:37
  • This project is quite old and big so this is reason why I still use struts.. – lucas999 Jan 05 '18 at 15:45
  • Migration to another framework generate extra costs.. what is not acceptable for clients. – lucas999 Jan 05 '18 at 16:44
  • 2
    @ArifMustafa Besides not being a helpful comment, the idea that Spring is "lightweight" is a little silly. All S2 is is an alternative MVC web app system. I might not use it for new projects, but the argument that it's "heavy" doesn't match the reality. – Dave Newton Jan 07 '18 at 21:18

1 Answers1

0

You can add interceptor to intercept the action and if the method is not POST then return error result. If you want to learn how to configure the result you can read this answer.

In the interceptor implementation you can use ServletActionContext.getRequest() similar to this answer.

Then use request.getMethod() to get the method of HTTP request.

Roman C
  • 49,761
  • 33
  • 66
  • 176
  • 1
    Thanks I was thinking about this solution but I thought that there is another solution builded in framework. – lucas999 Jan 05 '18 at 16:42
  • I'm not sure what do you think you could add to the question. If you are using REST plugin then you have a mapping of http methods to actions. – Roman C Jan 05 '18 at 18:14