struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <>
Subject Re: Struts2 Rest Mapper Taking Over Non Rest Json Result
Date Tue, 20 Sep 2016 18:45:22 GMT
To solve a similar issue I ended up creating my own ContentTypeHandler. As
you already have a result it should be pretty easy to wrap (at least I
found it so). The problem is that after doing so all JSON will be handled
by your new Content type...

While this link shows how to use Jackson, you can create your own
implementation and then apply your own configuration in the same way:

On Tue, Sep 20, 2016 at 12:34 PM, Paul Zepernick <> wrote:

> Thanks Martin, it was getting to the correct action class buy it was not
> using the result I defined in the action.  It was going to its own result
> implementation based on the fact that I am requesting an application/json
> data type.  I found out that if I add ".action" to the url it processes
> everything correctly and goes to the correct result.  I am not sure if that
> is the intended behavior, a setup issue on my part, or a bug?
> -----Original Message-----
> From: Martin Gainty []
> Sent: Tuesday, September 20, 2016 2:24 PM
> To: Struts Users Mailing List <>
> Subject: RE: Struts2 Rest Mapper Taking Over Non Rest Json Result
> to control navigation why not map it?<action name="grid/*"
> className="org.healthsmart.NonRestfulAction">    <param
> name="id">{1}</param>    ...</action>
> GET: /grid/method="index"when you reference /grid/ struts will call
> org.healthsmart.NonRestfulAction index method
> docs/restfulactionmapper.html
> ============or use DMI============
> <package name="default" extends="struts-default" strict-method-invocation="
> true">
>   <action name="grid" class="org.healthsmart.NonRestfulAction">
> <result name="success">/WEB-INF/content/hello.jsp</result>        <result
> name="redisplay" type="redirectAction">hello</result>
> <allowed-methods>add</allowed-methods>    </action>
> html#ActionConfiguration-ActionMappings
> I would check struts.mapper.prefixMapping for normal "rest prefixMapping
> vs struts prefixMapping" configuration
> restfulactionmapper.html
> if that looks ok as a last result you can implement a custom mapper which
> will read the URL and redirect to correct class programaticallyhttp://
> both-struts-actions-rest-actions-work-together-but
> Martin
> ______________________________________________
> > From:
> > To:
> > Subject: Struts2 Rest Mapper Taking Over Non Rest Json Result
> > Date: Tue, 20 Sep 2016 15:28:42 +0000
> >
> > This was also posted to stackoverflow and relevant config information
> can be seen in the post:
> questions/39593721/struts2-rest-mapper-taking-over-non-rest-json-result
> >
> > I am working with the DataTables JS library and am trying to write
> actions for the grid. I have a api in place that creates the json for me
> already and I just need to stream it back. I created a custom result to
> handle this, but the result mapped in the action never runs. No matter what
> the result type, the REST mapper tries to handle it as soon as it sees that
> application/json has been requested from the client. I have used the prefix
> mapping in the configuration to have all url's using /grid to bypass the
> rest mapper. It seems to be working in some capacity because it runs the
> correct interceptor stack and is using the @Action annotation information
> to map the url. However, the result specified is NOT running and is instead
> being provided by the rest mapper based on the stack trace I am receiving.
> I would like to completely bypass the rest mapper for any actions in the
> /grid namespace. Have I done something wrong in the configuration that is
> still causing rest to be involved in the request to those actions?
> >
> > Paul R. Zepernick
> > Sr. Programmer Analyst
> >
> >
> >
> >
> >
> >
> > Disclaimer: This communication and any files transmitted with it may
> contain information that is privileged, confidential and/or exempt from
> disclosure under applicable law. If you are not the intended recipient, you
> are hereby notified that any disclosure, copying, distribution, or use of
> the information contained herein (including any reliance thereon) is
> strictly prohibited. If you received this communication in error, please
> immediately contact the sender and destroy the material in its entirety,
> whether in electronic or hard copy format. Thank you.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Sent from my C64 using a 300 baud modem

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message