Forms Struts 2元';t将参数从ExtJS表单传输到ActionSupport类

Forms Struts 2元';t将参数从ExtJS表单传输到ActionSupport类,forms,extjs,struts2,struts,Forms,Extjs,Struts2,Struts,我正在实现一个简单的ExtJS表单,它提交给Struts 2 ActionSupport类。各部件的代码如下所示: MyAction.java: //packaging and imports public class MyAction extends ActionSupport { private String aField; private String anotherField; public String execute() throws Exception {

我正在实现一个简单的ExtJS表单,它提交给Struts 2 ActionSupport类。各部件的代码如下所示:

MyAction.java:

//packaging and imports
public class MyAction extends ActionSupport {
    private String aField;
    private String anotherField;

    public String execute() throws Exception {
        System.out.println(afield + " " + anotherField); //just checking values, atm
        return ActionSupport.SUCCESS;
    }

    public String getAField() {
        return this.aField;
    }

    public void setAField(String aField) {
        this.aField = aField;
    }

    public String getAnotherField() {
        return this.anotherField;
    }

    public void setAnotherField(String anotherField) {
        this.anotherField = anotherField;
    }
}
myForm.js:

Ext.onReady(function() {
    Ext.QuickTips.init();

    // turn on validation errors beside the field globally
    Ext.form.Field.prototype.msgTarget = 'side';

    var myForm = new Ext.form.FormPanel({
        id: 'myFormId',
        url: 'submitMyForm.action',
        defaults: {
            xtype: 'textfield'
        },
        items: [
            {
                fieldLabel: 'A Field',
                id: 'aField',
                name: 'aField',
                allowBlank: false
            },
            {
                fieldLabel: 'Another Field',
                id: 'anotherField',
                name: 'anotherField',
                allowBlank: false
            }
        ],
        renderTo: 'contentMain'
    });

    var submitButton = new Ext.Button({
        text: 'SUBMIT',
        handler: function(button, event) {
            myForm.getForm().submit({
                url: 'submitMyForm.action',
                failure: function() {
                    Ext.Msg.alert('Error', 'Can not save data.');
                }
            });
        }
    });
});
struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <package name="myPackage" namespace="/" extends="json-default">
        <action name="submitMyForm" class="mycodepackage.MyAction">
            <result name="*" type="json">
                <param name="includeProperties">aField</param>
            </result>
        </action>
    </package>
</struts>
JSON结果被正确地发回,但当然也是空的:

14:22:17,046DEBUG JSONResult:68 - Adding include property expression:  aField
14:22:17,052DEBUG JSONWriter:68 - Ignoring property because of include rule:  anotherField
14:22:17,053DEBUG JSONUtil:68 - [JSON]{"aField":null}
现在,我的理解是表单中输入的值应该插入到action类的实例变量中。我错了吗?如果没有,会出现什么问题?如果是这样,我可以做什么来确保表单数据被发送到我的操作处理程序


谢谢。

发送的任何参数都将被放入类似命名的setter中。为什么不先用LiveHttpHeaders Firefox插件检查表单参数是否正确发送。

一旦我们意识到表单数据没有正确地传递到http请求中,我的同事开发了一个表单数据拦截器,我们使用它手动加载数据。有关详细信息,请查看
标记。

您是对的,表单数据发送不正确。知道是什么原因吗?我一直在四处寻找,没有找到关于这个问题的任何东西。如果您有任何想法,我们将不胜感激。您能帮我解决以下问题吗:[运行应用程序时出现错误“没有为命名空间/和操作名登录映射的操作][1][1]:
14:22:17,046DEBUG JSONResult:68 - Adding include property expression:  aField
14:22:17,052DEBUG JSONWriter:68 - Ignoring property because of include rule:  anotherField
14:22:17,053DEBUG JSONUtil:68 - [JSON]{"aField":null}