Struts表单和请求属性为null(Struts 1.3)

时间:2015-02-24 15:16:18

标签: java struts

我遇到了一个微不足道的问题,但在过去的8年里没有完成Struts:D ...有人能指出我的代码有什么问题吗?提交好吗?我只是不知道为什么我的ProcessPaymentAction收到一个带有null参数的请求和一个带有空值的表单......

这是我的struts-config.xml文件......

    <action-mappings>
    <action path="/wpa"
        type="org.springframework.web.struts.DelegatingActionProxy" name="wpaForm"
        scope="session" input="page.wpa" validate="false">
        <forward name="success" path="page.success" />
    </action>

    <action path="/wpa2"
        type="org.springframework.web.struts.DelegatingActionProxy" name="wpaForm"
        scope="session" input="page.wpa2" validate="false">
        <forward name="success" path="page.success" />
    </action>

这是我的初始动作类,它提供表单...

    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Entering WPADispatchAction");
    }

    WPAForm wpaForm = (WPAForm) form;

    StateHelper.initClientType(request, response);
    ClientTypeEnum clientType = StateHelper.retrieveClientType(request);

    String planType = request.getParameter(RequestParamEnum.PLANT_TYPE.getParamName());
    String province = request.getParameter(RequestParamEnum.PROVINCE.getParamName());
    String language = request.getParameter(RequestParamEnum.LANGUAGE.getParamName());
    String userType = request.getParameter(RequestParamEnum.USER_TYPE.getParamName());
    String isPayableByCreditCard = request.getParameter(RequestParamEnum.PAY_BY_CC_ALLOWED.getParamName());

    request.getSession().setAttribute("language", language);

    wpaForm.setCryptCode(MonerisConfigHelper.retrieveMonerisCryptCode());
    wpaForm.setMonerisUrl(MonerisConfigHelper.retrieveMonerisURL());
    addResponseUrlCookie(response, 
    if (StringUtils.isNotBlank(isPayableByCreditCard)){
        wpaForm.setProcessPaymentByCard(Boolean.valueOf(isPayableByCreditCard));
    } else {
        wpaForm.setProcessPaymentByCard(false);
    }

以下是提交页面时调用的操作...

    @Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse reponse) throws Exception {

    if (log.isDebugEnabled()) {
        log.debug("Entering ProcessPaymentAction");
    }

    WPAForm wpaForm = (WPAForm) form;

    JSONObject json = new JSONObject();

    String sessionId = request.getParameter("sessionId");
    String amount = request.getParameter("amount");
    String policyID = request.getParameter("policyID");

在这里,我的表单和所有参数都为空...

这是提交表单的jsp ..

  <html:form action="/wpa2" styleId="wpaForm" method="post">

和javascript函数......

function submitForm() {

var theForm = document.getElementById("wpaForm");
if (planType == 'B') {
    theForm.action = "processhpcipayment.do";
} else if (planType == 'E') {
    theForm.action = "processmonthly.do";
}
document.getElementById("wpaForm").submit();

}

和我的表格......

public class WPAForm extends ActionForm {

/**
 * 
 */
private static final long serialVersionUID = 7519298876451952530L;

private String policyID;

private String amount;

private String storeID;

public String getPolicyID() {
    return policyID;
}

public void setPolicyID(String policyID) {
    this.policyID = policyID;
}

public String getStoreID() {
    return storeID;
}

public void setStoreID(String storeID) {
    this.storeID = storeID;
}
public String getAmount() {
    return amount;
}

public void setAmount(String amount) {
    this.amount = amount;
}

...

0 个答案:

没有答案