struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <>
Subject Re: labelizing submit buttons
Date Tue, 30 Nov 2010 13:50:20 GMT
I think your tag has a leak of attribute "method"

Your code:
<s:submit key="" />

will generate HTML likes:

<input type="submit" name="" value="Search"/>

When you click this button, there will be a http request parameter
like "".
Struts2 will accept this parameter, and try to save it to your action property.
So, there will be a property setting, which cause method invoking likes:

But your action does not have a property named "btn",
so getBtn() will get a null, and of cause the setSearch part will fail.

If you add a "method" attribute to submit tag, like:
<s:submit key="" method="search" />

It will generate HTML like:

<input type="submit" value="Search" name="method:search" />

Notice, the "name" is now "method:search"
So, when you click this button, the http request will be:

Struts will recognize the prefix "method:", so it know that this is a
flag to specify which method to execute, but not a input data which
need to be set in to property of Action.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message