In my Struts app, I have an action, called Foo.
<action name="Foo" class="some.path.here.foo">
<result name="SUCCESS" type="tiles">/foo.tiles</result>
</action>
Normally it calls execute(), but I want to call another method called change(). How can I do so?
My Idea was this:
<form name="Foo" action="Foo" >
<s:textfield name="Mail" placeholder="Mail" />
<select name="someselect">
<s:iterator value="someblabla">
<option value="<s:property value="somevalue"/>" label="<s:property value="Description"/>"><s:property value="Name"/></option>
</s:iterator>
</select>
<s:submit method="change" value="Go!"></s:submit>
</form>
But when I want to do this, I get
HTTP Status 404 - No result defined for action some.path.is.here.Foo and result input
Can you help me out here?
execute is the default method in an action. If you want to change it i think you can modify the description of your action with adding the "method" attribute. Like that :
<action name="Foo" class="some.path.here.foo" method="change">
<result name="SUCCESS" type="tiles">/foo.tiles</result>
</action>
Hope this help
You are getting error because, struts expects 'execute' method unless you specify explicitly. If your action method name is different, you have to specify it explicity using the parameter 'method'.
So your code should be
<action name="Foo" class="some.path.here.foo" method="change">
<result name="SUCCESS" type="tiles">/foo.tiles</result>
</action>
Struts 2 also supports wildcard methods and dynamic method invocation. DMI is less secure, and not preferred. See the docs here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.