views:

96

answers:

2

I have the following action declared in my struts.xml:

    <action path="/updateAccountInfo"
            type="org.myCompany.UpdateAccountAction"
            name="myAccountForm"
            scope="session"
            validate="true"
            parameter="method" 
            input="/updateAccountInfo.jsp">
        <forward name="success" path="/updateAccountInfo.jsp" />
    </action>

In my JSP page, I have the following form:

<html:form action="/updateAccountInfo.do">
    <input type="hidden" name="method" value="sendMessage" />

In my java class, I have the following method:

public final ActionForward sendMessage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    System.out.println("sending");
    return null;
}

Instead of running sendMessage, Struts call the execute method. Why? Is my struts-config wrong? Or am I missing another config setting?

+1  A: 

Does your UpdateAccountAction extend DispatchAction? Here's a working example that does what you're trying to do.

Pat
Yes, it does extend DispatchAction. I'll try comparing my code to the example and see if I can spot any differences.....
David
+4  A: 

Please first make sure that your action extends DispatchAction. You probably should not override the execute method in that class since that method is responsible for extracting the request parameter and invoking the corresponding method. If you override execute this logic will no longer execute.

Jörn Horstmann
I was overriding the execute method. That seems to be breaking the DispatchAction's method calling logic....
David