参数“方法"为“参数".不起作用(Struts 1) [英] Parameter "method" not working (Struts 1)

查看:84
本文介绍了参数“方法"为“参数".不起作用(Struts 1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在struts.xml中声明了以下操作:

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>

在我的JSP页面中,我具有以下形式:

In my JSP page, I have the following form:

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

在我的java类中,我具有以下方法:

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;
}

Struts代替运行sendMessage,而是调用execute方法.为什么?我的struts-config错误吗?还是我缺少其他配置设置?

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

推荐答案

请首先确保您的操作扩展了DispatchAction.您可能不应覆盖该类中的execute方法,因为该方法负责提取请求参数并调用相应的方法.如果您覆盖执行,则该逻辑将不再执行.

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.

这篇关于参数“方法"为“参数".不起作用(Struts 1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆