现在我有2个以下JavaScript函数:如何将条件包含到组合的JSP和JavaScript函数中?
function clearBillingCache(){
window.location = "billingSearchClear.html"
}
function clearBillingCache_1(){
<%
request.getSession().setAttribute("stickyCarrier", null);
request.getSession().setAttribute("stickyAgency", null);
%>
}
如何有一个组合的功能,所以只有当request.getSession()的getAttribute( “stickyCarrier”)= NULL 做到以下几点:!
<%
request.getSession().setAttribute("stickyCarrier", null);
request.getSession().setAttribute("stickyAgency", null);
%>
window.location = "billingSearchClear.html"
否则什么都不做。
编辑:
谢谢Bhaskara!
但实际上它比我表现出更多的,它可能会进入一个无限循环,因为在一个重定向:
@RequestMapping(value = "/billingSearchClear.html", method = RequestMethod.GET)
public String clearCache(HttpServletRequest request) {
String returnVal = "redirect:/billingSearch.html";
request.getSession().setAttribute("stickyCarrier", null);
request.getSession().setAttribute("stickyAgency", null);
return returnVal;
}
而且我在<body onload=...>
弗兰克,我在你的新编辑后更新了我的答案。我的理解是用户点击链接,然后检查是否有会话属性,如果有会话属性,请将其删除并将用户发送到/billingSearch.html。如果我的理解错误,请纠正我 – Bhaskara 2014-11-26 17:45:38