You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Christoph Kepper <ke...@diefirma.de> on 2008/03/13 09:25:50 UTC
Problem accessing GET parameter in Struts2
Hi,
I am new to Struts and new to this list. I want to create a blog with
struts as a university project and have been wrestling with this
(obscenely) simple problem for two days without any progress. Maybe any
of you struts experts may help out here:
All I want to do is access a GET parameter from an action to initialize
an article object. This is how my URL looks like:
http://localhost:8080/struts_blog/artikel.action?artnr=1
In my struts.xml I specified an action that is correctly mapped to my
action class:
<action name="artikel" method="input" class="action.ArtikelAction">
<result name="success" type="redirectAction">admin</result>
<result name="input">/WEB-INF/jsp/artikelForm.jsp</result>
</action>
My action class (ArtikelAction.java) contains the property "private
Integer artnr" with the appropriate Getters and Setters. From what I
read in the documentation and saw in the examples, this should be
sufficient for the params interceptor to initialize the variable.
However, this is not the case :-(
What am I missing?
I tried to get some debug information from the params interceptor and
put the following code into my struts.xml (inside the action):
<interceptor-ref name="params">
<param name="logEnabled">true</param>
<param name="logLevel">DEBUG</param>
</interceptor-ref>
However, this just gave me the following exception when starting my project:
13.03.2008 09:18:42 com.opensymphony.xwork2.util.OgnlUtil
internalSetProperty
WARNUNG: Caught OgnlException while setting property 'logLevel' on type
'com.opensymphony.xwork2.interceptor.ParametersInterceptor'.
ognl.NoSuchPropertyException:
com.opensymphony.xwork2.interceptor.ParametersInterceptor.logLevel
So, how could I debug the params interceptor?
I am using the latest struts-2.0.11.1 release libraries and have set
devMode to true in struts.xml.
Thanks for your help.
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem accessing GET parameter in Struts2
Posted by Christoph Kepper <ke...@diefirma.de>.
Thanks to your hint I found the mistake :-)
Dave Newton wrote:
>> I tried to get some debug information from the params interceptor and
>> put the following code into my struts.xml (inside the action):
>> <interceptor-ref name="params">
>> <param name="logEnabled">true</param>
>> <param name="logLevel">DEBUG</param>
>> </interceptor-ref>
>
> Nate that when you use an interceptor-ref element inside an action
> configuration then *only* that interceptor-ref will be configured for that
> action: this means that in this case if this is the only interceptor-ref
> inside the action element then *only* the "params" interceptor will be run
> for that action. This is probably not what you want.
>
After inserting the basicStack interceptor into the action, the variable
was correctly initialized:
<interceptor-ref name="params" />
<interceptor-ref name="basicStack" />
Nevertheless, I still don't get any log info from the interceptors.
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem accessing GET parameter in Struts2
Posted by Dave Newton <ne...@yahoo.com>.
--- Christoph Kepper <ke...@diefirma.de> wrote:
> <action name="artikel" method="input" class="action.ArtikelAction">
> <result name="success" type="redirectAction">admin</result>
> <result name="input">/WEB-INF/jsp/artikelForm.jsp</result>
> </action>
>
> My action class (ArtikelAction.java) contains the property "private
> Integer artnr" with the appropriate Getters and Setters.
As a sanity check, what are your getter and setters named?
> I tried to get some debug information from the params interceptor and
> put the following code into my struts.xml (inside the action):
> <interceptor-ref name="params">
> <param name="logEnabled">true</param>
> <param name="logLevel">DEBUG</param>
> </interceptor-ref>
Nate that when you use an interceptor-ref element inside an action
configuration then *only* that interceptor-ref will be configured for that
action: this means that in this case if this is the only interceptor-ref
inside the action element then *only* the "params" interceptor will be run
for that action. This is probably not what you want.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org