You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Cartwright <Jo...@noaa.gov> on 2009/08/25 01:17:46 UTC
S2: reading POST body w/in action
Hello All,
I'm trying to read the body of a POST, e.g. XML content, w/in an
Action. Problem seems to be protecting it from the
ParametersInterceptor so that the body of the request is not treated as
key-value pairs.
Can someone please help me with this?
Thanks!
--john
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: S2: reading POST body w/in action
Posted by Martin Gainty <mg...@hotmail.com>.
assuming this configuration in struts.xml
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="staticParams">
<param name="parse">true</param>
<param name="overwrite">false</param>
</interceptor-ref>
<result name="success">good_result.ftl</result>
</action>
init params would populate parameters (Map) as in this example
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor @Override
public String intercept(ActionInvocation invocation) throws Exception
{
ActionConfig config = invocation.getProxy().getConfig();
Object action = invocation.getAction();
final Map<String, String> parameters = config.getParams();
java.util.Iterator iter= parameters.values().iterator();
while(iter.hasNext()
{
Object obj=iter.next();
System.out.println("key="+obj);
System.out.println("value = "+parameters.get(obj));
}
does the xml example above conform to your schema?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Mon, 24 Aug 2009 17:17:46 -0600
> From: John.C.Cartwright@noaa.gov
> Subject: S2: reading POST body w/in action
> To: user@struts.apache.org
>
> Hello All,
>
> I'm trying to read the body of a POST, e.g. XML content, w/in an
> Action. Problem seems to be protecting it from the
> ParametersInterceptor so that the body of the request is not treated as
> key-value pairs.
>
> Can someone please help me with this?
>
> Thanks!
>
> --john
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
Re: S2: reading POST body w/in action
Posted by John Cartwright <Jo...@noaa.gov>.
Thanks for your suggestion Greg, that makes sense and I'll give it a try.
--john
Greg Lindholm wrote:
> You will want to use a custom interceptor stack that does not include the
> ParametersInterceptor.
> I would start with a copy of the defaultStack (see [1]) and remove any
> interceptors you don't need (which will be most of them). You will probably
> want to keep the servletConfig interceptor [2] and implement
> ServletRequestAware in your action to get the HttpServletRequest.
>
> [1] http://struts.apache.org/2.1.6/docs/struts-defaultxml.html
> [2]
> http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/interceptor/ServletConfigInterceptor.html
>
> P.S. You can usually ignore anything that Martin Gainty writes. (Wasn't
> someone going to ban him already.)
>
>
> On Mon, Aug 24, 2009 at 7:17 PM, John Cartwright <John.C.Cartwright@noaa.gov
>
>> wrote:
>>
>
>
>> Hello All,
>>
>> I'm trying to read the body of a POST, e.g. XML content, w/in an
>> Action. Problem seems to be protecting it from the
>> ParametersInterceptor so that the body of the request is not treated as
>> key-value pairs.
>>
>> Can someone please help me with this?
>>
>> Thanks!
>>
>> --john
>>
>>
>> ---------------------------------------------------------------------
>> 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: reading POST body w/in action
Posted by Greg Lindholm <gr...@gmail.com>.
You will want to use a custom interceptor stack that does not include the
ParametersInterceptor.
I would start with a copy of the defaultStack (see [1]) and remove any
interceptors you don't need (which will be most of them). You will probably
want to keep the servletConfig interceptor [2] and implement
ServletRequestAware in your action to get the HttpServletRequest.
[1] http://struts.apache.org/2.1.6/docs/struts-defaultxml.html
[2]
http://struts.apache.org/2.1.6/struts2-core/apidocs/org/apache/struts2/interceptor/ServletConfigInterceptor.html
P.S. You can usually ignore anything that Martin Gainty writes. (Wasn't
someone going to ban him already.)
On Mon, Aug 24, 2009 at 7:17 PM, John Cartwright <John.C.Cartwright@noaa.gov
> wrote:
> Hello All,
>
> I'm trying to read the body of a POST, e.g. XML content, w/in an
> Action. Problem seems to be protecting it from the
> ParametersInterceptor so that the body of the request is not treated as
> key-value pairs.
>
> Can someone please help me with this?
>
> Thanks!
>
> --john
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>