我的javascript中有两个点击方法,如下所示。方法1是按照控制器方法,但在此之后单击方法2的按钮时,它没有按下控制器。在这里,我不想使用$ .ajax调用提交。我尝试了不同的方法但不确定为什么方法2没有击中控制器。感谢任何输入。感谢。
Method 1:
$("#selectAll").click(function () {
var familyDetailsForm = $("#family_details");
var enrollmentSetupId = $("#enrollmentSetupId").val();
var eId = $("#eId").val();
var url = "";
if($("#isDental").val() == "true"){
url = GlobalVars["app_url"] + "/shop/search/addAllDentalPlans?enrollmentSetupId=" +
enrollmentSetupId+"&eId="+eId;
}
else {
url = GlobalVars["app_url"] + "/shop/search/addAllHealthPlans?enrollmentSetupId=" +
enrollmentSetupId+"&eId="+eId;
}
familyDetailsForm.attr("action", url);
familyDetailsForm.submit();
});
Method 2:
$("#removeAll").click(function () {
var remove_familyDetailsForm = $("#family_details");
var remove_enrollmentSetupId = $("#enrollmentSetupId").val();
var planType = $("#planKind").val();
var url = "";
if($("#isDental").val() == "true"){
url = GlobalVars["app_url"] + "/shop/search/removeAllDentalPlans?
remove_enrollmentSetupId=" +remove_enrollmentSetupId+"&planType="+planType;
}
else {
url = GlobalVars["app_url"] + "/shop/search/removeAllHealthPlans?
remove_enrollmentSetupId=" +remove_enrollmentSetupId+"&planType="+planType;
}
remove_familyDetailsForm.attr("action", url);
remove_familyDetailsForm.submit();
});
Controller:
@RequestMapping(value = "removeAllHealthPlans", method = RequestMethod.POST)
public String removeAllHealthPlans(HttpSession session, HttpServletRequest request, Model model)
throws Exception {
答案 0 :(得分:0)
首先检查您的方法是否已正确映射。应该是
@RequestMapping(value = "/removeAllHealthPlans", ...)
这当然假设你的控制器被映射为/ shop / search