struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Burton Rhodes <burtonrho...@gmail.com>
Subject Re: Unable to change content-type with Interceptor?
Date Sun, 30 Dec 2012 17:49:09 GMT
Just tried that without success.  Oddly, even when I debug the code, the
reponse.contentType is not changed immediately after the line:
response.setContentType("text/plain").  I am wondering if the contentType
cannot be set twice (or overridden once set)?


On Sun, Dec 30, 2012 at 11:39 AM, Lukasz Lenart <lukaszlenart@apache.org>wrote:

> 2012/12/30 Burton Rhodes <burtonrhodes@gmail.com>:
> > I'm not sure what I'm doing wrong, but I cannot for the life of me change
> > the content-type of the response using an interceptor.  My interceptor
> code
> > is below.  The example below seems a bit absurd, but eventually I will
> add
> > code to change the content-type dynamically from "application/json" to
> > "text/plain" depending on what the request will "accept" (this is to fix
> an
> > IE bug related to ajax file uploads).  What am I missing here?  Many
> thanks
> > in advance.
> >
> > <!-- struts.xml snippit -->
> > <package name="jsonSecure" namespace="/app/json" extends="json-default">
> >
> >     <interceptors>
> >         <interceptor name="jsonDynamicContentType"
> > class="com.afs.web.interceptor.JsonDynamicContentTypeInterceptor"/>
> >         <interceptor-stack name="dynamicContentType">
> >             <interceptor-ref name="json"/>
> >             <interceptor-ref name="jsonDynamicContentType"/>
> >         </interceptor-stack>
> >     </interceptors>
>
> Did you try to change order of the interceptors? Interceptors are
> executed in FILO - First-In-Last-Out - which means json interceptor
> will be executed as the first one, but when action was executed and
> result will be forwarded back, json interceptor will be executed as
> the last one:
>
> json->jsonDynamicContentType->action->result->jsonDynamicContentType->json
>
> http://struts.apache.org/2.x/docs/interceptors.html
>
>
> 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
>
>

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