在写ajax与springboot后台通信时,出现了以下的错误
Circular view path [success]: would dispatch back to the current handler URL [/success] again
前端ajax程序:
$.ajax({
type: "POST",
url: "/people_numChart",
contentType: "apllication/json",
dataType: "json",
success:function(data){
console.log(data);
}
})
后端spriongBoot程序:
@RequestMapping("/people_numChart")
public JSONArray people_num(){
//省略中间代码
return people_numChart.getChartData("实时总人数");
}
然后出现了标题的错误。
出现这种错误的原因一般是映射处理这个url请求的控制器 方法返回值问题
1.比如没有跳转页面,没有返回对象(即void)则报错
2.控制器处理方法跳转到映射的请求反复也会如此
解决办法
在springboot的controller方法前加一个注解
@ResponseBody
问题便解决了