【发布时间】:2015-11-01 00:57:08
【问题描述】:
我正在使用一个 Spring MVC 控制器,它将返回一个布尔值作为对 ajax 请求的响应。但是,当 spring mvc 试图返回一个布尔值时,它给了我 服务器响应状态为 406(不可接受)错误请帮助。提前致谢
这是我的控制器
@Controller
public class MainController {
@RequestMapping(value="/check.html",method=RequestMethod.POST)
public @ResponseBody Boolean checkValue(){
return true;
}
}
这是我的 Ajax 方法
<script type="text/javascript">
function doAjax() {
$.ajax({
type : "post",
url : 'check.html',
success : function(response) {
if(response===true)
{
window.alert("true");
}
else
{
window.alert("false");
}
},
error : function(e){
window.alert("error");
}
});
}
</script>
【问题讨论】:
标签: jquery ajax spring spring-mvc