spring mvc中通过ajax请求台后,请求不到0
配置如下:
web.xml中DispatcherServlet的配置
springMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:/META-INF/springMVC.xml
1
springMVC
/
springMVC.xml的配置
controller类
@Controller
@RequestMapping("/hello/default.do")
public class HelloController {
@RequestMapping(params = "method=sayHello")
public ModelAndView sayHello(HttpServletRequest request) {
Hello hello = new Hello(RequestUtil.getMap(request));
System.out.println("sayHello");
return new ModelAndView("jsonView", hello.syaHello());
}
}
ajax请求
js方法:
function ajaxGet(url,data,success){
$.ajax({
url: url,
type: "GET",
data: data ,
dataType: "json",
success: success,
error: function(XMLHttpRequest,textStatus,errorThrown){
alert(errorThrown);
}
});
}
请求:
ajaxGet("/hello/default.do?method=sayHello",{name:"sjh"},function(){
alert("A");
});
ajax 错误提示为 "not found",为什么老请求不到呢,我写的url有什么问题吗?求解...