exclude params submit

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

exclude params submit

José Antonio Delgado Trujillo
I have a form with several tags using the attribute key.

As it is said in getting started / message resource file
Key is used to substitute tag’s value and label attributes.

For example: <s:textField key=“person.name”/>

To put the tag label Struts2 look for property file.
To put the tag value Struts2 look for setName of a bean person instantiated by the action class.

So <s:submit key=“Submit”> produces the next error:
18:27:10,990 ERROR [stderr] (default task-9) Unexpected Exception caught setting 'submit' on 'class uoc.jdelgadot.loginstruts.action.Login: Error setting expression 'submit' with value ['Acceder', ]

To avoid this in getting started / elude params say to configure a new stack filter with exclude params.


I have the next Form
——
<s:form action = "login">
                <s:textfield key="credentialBean.user" />
                <s:password key="credentialBean.pass" />
                <s:submit key="submit" />
        </s:form>
——


This is my properties file

credentialBean.user=Usuario
credentialBean.pass=Contraseña
submit=Acceder



This is my trusts.xml configuration

<struts>
        <constant name="struts.devMode" value="true" />
       
        <package name="loginstruts" extends="struts-default”>

        <interceptors>
                <interceptor-stack name="appDefault">
                        <interceptor-ref name="defaultStack">
                                <param name="params.excludeParams">dojo..*,^struts..*,^session..*,^request..*,^application..*,^servlet(Request|Response)..*,parameters...*,submit</param>
                        </interceptor-ref>
                </interceptor-stack>
        </interceptors>
       
        <default-interceptor-ref name="appDefault"/>

...


Still i’ve got submit error.
What am i doing wrong?


Un saludo,
José A.

Reply | Threaded
Open this post in threaded view
|

Re: exclude params submit

Yasser Zamani-2


On 1/2/2018 10:38 PM, José Antonio Delgado Trujillo wrote:
> So <s:submit key=“Submit”> produces the next error:
> 18:27:10,990 ERROR [stderr] (default task-9) Unexpected Exception caught setting 'submit' on 'class uoc.jdelgadot.loginstruts.action.Login: Error setting expression 'submit' with value ['Acceder', ]

When there is no setter for given parameter name, a warning message like
above will be logged in devMode. Thus is expected behaviour to allow
developer to spot missing setter or typo in either parameter name or
setter. You can simply ignore this one and if all such warning logs were
ok, set struts.devMode to false to disable this message when you deploy
to production.

Hope this helps.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: exclude params submit

José Antonio Delgado Trujillo
But it must fix with exclude param
 
https://struts.apache.org/getting-started/exclude-parameters.html <https://struts.apache.org/getting-started/exclude-parameters.html>


> On 3 Jan 2018, at 05:48, Yasser Zamani <[hidden email]> wrote:
>
>
>
> On 1/2/2018 10:38 PM, José Antonio Delgado Trujillo wrote:
>> So <s:submit key=“Submit”> produces the next error:
>> 18:27:10,990 ERROR [stderr] (default task-9) Unexpected Exception caught setting 'submit' on 'class uoc.jdelgadot.loginstruts.action.Login: Error setting expression 'submit' with value ['Acceder', ]
>
> When there is no setter for given parameter name, a warning message like
> above will be logged in devMode. Thus is expected behaviour to allow
> developer to spot missing setter or typo in either parameter name or
> setter. You can simply ignore this one and if all such warning logs were
> ok, set struts.devMode to false to disable this message when you deploy
> to production.
>
> Hope this helps.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: exclude params submit

Lukasz Lenart
2018-01-03 9:47 GMT+01:00 José Antonio Delgado Trujillo <[hidden email]>:
> But it must fix with exclude param
> https://struts.apache.org/getting-started/exclude-parameters.html <https://struts.apache.org/getting-started/exclude-parameters.html>

No, you don't have to, as Yasser said, this happens only in devMode.
Once disabled, Struts will ignore missing setters/parameters. Maybe we
should use a better error message.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]