jsp處理請求路徑的小技巧
阿新 • • 發佈:2018-12-21
$.ajax({
type: "post",
url: "",
data: ""
dataType: "json",
success: function(data){
}
});
這裡除了寫相對路徑以外,還可以在html的底部寫一個input type=hidden的標籤
<input type="hidden" id="hdnContextPath" name="" value="<%=request.getContextPath() %>"/>
使用$("#hdnContextPath").val()就拿到應用名,就可以寫成絕對路徑了