You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Benedict <pb...@apache.org> on 2013/03/18 16:42:22 UTC

S2 annotations to limit HTTP methods?

Does S2 have annotations, which can be applied to an action method, to
explicitly specify which HTTP methods are allowed? Thus returning a 405
otherwise?

Paul

Re: S2 annotations to limit HTTP methods?

Posted by Maurizio Cucchiara <mc...@apache.org>.
As far as I can remember there is something in the rest plugin, but it
would not be difficult to write an interceptor (maybe using rest plugin
code as hint).


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara

Maurizio Cucchiara


On 18 March 2013 16:42, Paul Benedict <pb...@apache.org> wrote:

> Does S2 have annotations, which can be applied to an action method, to
> explicitly specify which HTTP methods are allowed? Thus returning a 405
> otherwise?
>
> Paul
>

Re: S2 annotations to limit HTTP methods?

Posted by Dian Aditya <di...@meruvian.org>.
Hi,

Take a look at http://java.net/projects/s2restplugins<http://java.net/projects/s2restplugins/pages/Home>,
our team has developed
struts2 plugin that have annotation similar to Convention plugin's
annotation, with the
additional property like @Action(name="myaction", method=HttpMethod.GET)

You only need to put @Action on the method to specify wich http methods
will be handled
by annotated method

On Tue, Mar 19, 2013 at 2:16 AM, Paul Benedict <pb...@apache.org> wrote:

> I see that javax.ws.rs has @GET, @POST, etc. annotations that can @Target
> a
> method. Those seem like a good choice, but they are unfortunately part of
> the web services package. Too bad they weren't part of the common Servlet
> support! However, javax.servlet.annotation has @ServletSecurity that allows
> a list of methods being defined. Is that a better choice?
>
> My use case is that I want S2 AJAX actions that submit data to only be
> accessed via POST.
>
> Paul
>
> On Mon, Mar 18, 2013 at 1:25 PM, Lukasz Lenart <lukaszlenart@apache.org
> >wrote:
>
> > 2013/3/18 Paul Benedict <pb...@apache.org>:
> > > Does S2 have annotations, which can be applied to an action method, to
> > > explicitly specify which HTTP methods are allowed? Thus returning a 405
> > > otherwise?
> >
> > As I can recall, no - but if could describe a more specific case we
> > can add them. It isn't the first time that somebody is asking about
> > such a functionality.
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>



-- 
Dian Wahyu Aditya
Meruvian

Re: S2 annotations to limit HTTP methods?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/19 Maurizio Cucchiara <mc...@apache.org>:
> IMHO supporting http request method could be a value added: sometime
> you have to define a something.action and a doSomething.action (as
> example see fileupload action definition [1]) in order to define an
> input action (usually request by a get method) and the final action
> submitted by a post request.
>
> Obviously this would imply a change in xml dtd/definition and so on.

Not really, as we can just support that via annotations, leaving xml
based changes till S3


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S2 annotations to limit HTTP methods?

Posted by Maurizio Cucchiara <mc...@apache.org>.
IMHO supporting http request method could be a value added: sometime
you have to define a something.action and a doSomething.action (as
example see fileupload action definition [1]) in order to define an
input action (usually request by a get method) and the final action
submitted by a post request.

Obviously this would imply a change in xml dtd/definition and so on.

[1] http://goo.gl/WjkwK

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara

Maurizio Cucchiara


On 18 March 2013 21:38, Lukasz Lenart <lu...@apache.org> wrote:
> 2013/3/18 Paul Benedict <pb...@apache.org>:
>> I see that javax.ws.rs has @GET, @POST, etc. annotations that can @Target a
>> method. Those seem like a good choice, but they are unfortunately part of
>> the web services package. Too bad they weren't part of the common Servlet
>> support! However, javax.servlet.annotation has @ServletSecurity that allows
>> a list of methods being defined. Is that a better choice?
>>
>> My use case is that I want S2 AJAX actions that submit data to only be
>> accessed via POST.
>
> Is it related to the REST plugin? If so adding additional annotations
> and related interceptor should be piece of cake ;-)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S2 annotations to limit HTTP methods?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/18 Paul Benedict <pb...@apache.org>:
> I see that javax.ws.rs has @GET, @POST, etc. annotations that can @Target a
> method. Those seem like a good choice, but they are unfortunately part of
> the web services package. Too bad they weren't part of the common Servlet
> support! However, javax.servlet.annotation has @ServletSecurity that allows
> a list of methods being defined. Is that a better choice?
>
> My use case is that I want S2 AJAX actions that submit data to only be
> accessed via POST.

Is it related to the REST plugin? If so adding additional annotations
and related interceptor should be piece of cake ;-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: S2 annotations to limit HTTP methods?

Posted by Paul Benedict <pb...@apache.org>.
I see that javax.ws.rs has @GET, @POST, etc. annotations that can @Target a
method. Those seem like a good choice, but they are unfortunately part of
the web services package. Too bad they weren't part of the common Servlet
support! However, javax.servlet.annotation has @ServletSecurity that allows
a list of methods being defined. Is that a better choice?

My use case is that I want S2 AJAX actions that submit data to only be
accessed via POST.

Paul

On Mon, Mar 18, 2013 at 1:25 PM, Lukasz Lenart <lu...@apache.org>wrote:

> 2013/3/18 Paul Benedict <pb...@apache.org>:
> > Does S2 have annotations, which can be applied to an action method, to
> > explicitly specify which HTTP methods are allowed? Thus returning a 405
> > otherwise?
>
> As I can recall, no - but if could describe a more specific case we
> can add them. It isn't the first time that somebody is asking about
> such a functionality.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: S2 annotations to limit HTTP methods?

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/18 Paul Benedict <pb...@apache.org>:
> Does S2 have annotations, which can be applied to an action method, to
> explicitly specify which HTTP methods are allowed? Thus returning a 405
> otherwise?

As I can recall, no - but if could describe a more specific case we
can add them. It isn't the first time that somebody is asking about
such a functionality.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org