为什么Struts1 ajax ActionForm值都为空

为什么Struts1 ajax ActionForm值都为空,ajax,action,struts-1,Ajax,Action,Struts 1,在Struts1项目中,我试图发送ajax, chrome请求有效负载正常{“account”:“abcd”,“pwd”:“1234”} 但在debugMode中,actionForm的值都为null ajax领域: function loging() { alert(getFormData()); $.ajax({ url : '${pageContext.request.contextPath}/hello.do?method=json

在Struts1项目中,我试图发送ajax,
chrome请求有效负载正常{“account”:“abcd”,“pwd”:“1234”}
但在debugMode中,actionForm的值都为null

ajax领域:

function loging() {
        alert(getFormData());
        $.ajax({
            url : '${pageContext.request.contextPath}/hello.do?method=jsonHi',
            type : 'POST',
            data : getFormData(),
            contentType : 'application/json',
            dataType : 'json',
            async:false,
            success : function(data) {
                alert("success");
            },
            error : function() {
                alert("error!");
            }
        });
    }
function getFormData() {
        return JSON.stringify({
            'account' : $("#account").val(),
            'pwd' : $("#pwd").val()
        });
    };
struts配置区域:

<struts-config>
<form-beans>
    <form-bean name="formClass" type="com.pete.form.AccountForm" />
</form-beans>

<action-mappings>
    <action name="formClass" path="/hello" parameter="method" type="com.pete.action.HelloAction" scope="request" validate="false">
        <forward name="helloUser" path="/WEB-INF/pages/hello.jsp" />
        <forward name="jsonHi" path="/WEB-INF/pages/afterAjax.jsp"/>
    </action>
</action-mappings>
行动区:

    public class HelloAction extends DispatchAction {
    public ActionForward jsonHi(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        AccountForm reqForm = (AccountForm) form;
        System.out.println(reqForm.getAccount());//console is null
        System.out.println(reqForm.getPwd());// console is null
        return null;
    }

}

我不知道会发生什么情况表单的值为空

我发现问题是我的ajax不是表单提交,如果我想获取值 我必须使用HttpServletRequest getReader()

    public class HelloAction extends DispatchAction {
    public ActionForward jsonHi(ActionMapping mapping, ActionForm form, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        AccountForm reqForm = (AccountForm) form;
        System.out.println(reqForm.getAccount());//console is null
        System.out.println(reqForm.getPwd());// console is null
        return null;
    }

}