![](/img/trans.png)
[英]how to redirect from servlet to jsp using ajax instead of request dispatcher
[英]JSP/Servlet How to identify if the HTTP request came from an ajax request
我正在使用JQuery-Ajax和History.js作為我的網絡應用程序,無論如何我可以確定請求是來自AJAX請求還是只是正常請求? 我的目標是做這樣的事情
<%if(isRequestAjax()){%>
<jsp:include page="/views/header.jsp" />
}
<%}%>
<div id ="profilePage>
<!-- user profile will be loaded here !-->
</div>
我也使用Struts2作為MVC框架
您必須檢查請求標頭X-Requested-With
它將是XMLHttpRequest
if ("XMLHttpRequest".equals(req.getHeader("X-Requested-With")) ){
// include other file
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.