$(
function(){
$(“#uname”).blur(
function(){
$.get(“test/testJson”, “uname=”+$(this).val(), rollback(), “test”);
}
);
function rollback(data){
alert(data);
}
}
);
利用out对象response.getWriter().print()
@RequestMapping(“/testJson”)
public void testJson(String uname, HttpServletResponse response){
boolean flag = check(uname);
response.setContentType(“text/html;charset=utf-8”);
String flagString = flag?”用户名已经被占用”:”用户名可用”;
response.getWriter().print(JSON.toJSONString(flagString));
}
这个方法不需要跳转到任何方法,不需要进行任何跳转, 不能有返回值