-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