不是在jQuery中通过Ajax调用java Action

时间:2014-01-14 14:43:03

标签: java jquery struts2

vehicleinfo.js

function updateWCPolicyPresentValue(changedValue){
    var url = $.url($(this).prop('href'));
    var id = url.param('id');
    alert(id);
    if(confirm("Change will apply to all vehicles for this policy. Is it okey?")){
        $.ajax({
        url: '<s:url action="wcPolicyPresentVehicleInformationAction" namespace="/" />?   changedValue='+changedValue+'&keepUrlRegistry=true',
            cache : false,
            success : alert(changedValue)
        });
    }else{
        $.unblockScreen();
    }

    return false;

}

Struts的cpp.xml

<action name="*VehicleInformationAction" method="{1}"    class="com.sbi.fremont.bindexpress.cpp.web.action.VehicleInformationAction">
        <result name="input" type="tiles">vehicleInformationPageCpp</result>
        <result name="load" type="redirectAction">inputVehicleInformationAction?id=${selectedId}&amp;loadType=${loadType}&amp;fleetMessage=${fleetMessage}</result>
</action>
  1. 在这里,我试图通过ajax请求调用vehicleInformationAction java类,但它没有调用。我想检查一下ajax格式有什么错误吗?

1 个答案:

答案 0 :(得分:0)

更改

<result name="load" type="redirectAction">
    inputVehicleInformationAction?id=${selectedId}&amp;loadType=${loadType}&amp;fleetMessage=${fleetMessage}
</result>

<result name="load" type="redirectAction">
    <param name="actionName">inputVehicleInformationAction</param>
    <param name="id">${selectedId}</param>
    <param name="loadType">${loadType}</param>
    <param name="fleetMessage">${fleetMessage}</param>
</result>