-1
我有一個寧靜的項目,在春季mvc中使用它jquery code.when我的項目是寧靜的,jquery中的所有代碼無法正常工作,但當它不安靜時,所有的jquery代碼都可以正常運行。如何在春天安靜地使用jquery代碼?
這是我的jQuery代碼。
function doAjaxPost() {
// get the form values
$.ajax({
type: "POST",
url:"/login.htm",//note in restful url change to
*** http://localhost:8080/myproject/login ***
data: "username=" + username + "&password=" + password,
success: function(response){
// we have the response
if(response.status == "SUCCESS"){
//++++++++++
}else{
//++++++++++
}
}
},
});
}
和我的控制器代碼是這樣的:
@RequestMapping(value="/login.htm",method=RequestMethod.POST)
public @ResponseBody JsonResponse login(@ModelAttribute(value="user") User user) {
//==============================
}
這個代碼運行正常,但如果將其更改爲寧靜不工作。 我的代碼問題是什麼?
它的工作原理,如果你硬編碼路徑:
閱讀本?你是否設置了contextPath值? – 2014-09-01 14:46:41
嘗試用$ {pageContext.request.contextPath}替換contextPath變量 – 2014-09-01 15:35:24