后台代码
/**
* 账号是否存在
* @param account
* @return
*/
@RequestMapping(value = "/validateAccountNonExistent.json", method = RequestMethod.GET)
@ResponseBody
public JsonData validateActNonExistent(@RequestParam String account){
System.out.println(account+"============account");
if(sysUserService.checkTelephoneExist(account, null)){
System.out.println("true");
return JsonData.success();
}else if(sysUserService.checkEmailExist(account, null)){
System.out.println("true");
return JsonData.success();
}else{
System.out.println("false");
return JsonData.fail("账号不存在");
}
}
后台拦截器拦截到的日志信息
================================================================================================
2019-03-14 11:26:11.162 INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor : request start. servletPath:/sys/user/validateAccountNonExistent.json, methodType:GET
2019-03-14 11:26:11.162 INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor : request start. url:/assets/sys/user/validateAccountNonExistent.json, params:{"account":["admin@qq.com"],"_":["1552533963678"]}
servletPath==========/sys/user/validateAccountNonExistent.json
2019-03-14 11:26:11.162 INFO 15436 --- [nio-8081-exec-3] com.hdcs.interceptor.HttpInterceptor : request completed. url:/assets/sys/user/validateAccountNonExistent.json, cost:0
js
callback: function (value, validator, $field) {
var bol = true;
$.ajax({
type: "get",
url: "/assets/sys/user/validateAccountNonExistent.json",
cache : false,
async : false,
data: {
account:value
},
success: function(data) {
console.log(data.ret);
if(!data.ret){
bol = false;
}
},
error: function () {
console.log("caocaocaocao");
bol = false;
}
});
return bol;
}
说明:前台,浏览器F12 network中访问正确200,后台拦截器也拦截到了数据,但是后台没有进方法,连输出语句都没有输出,ajax会走error:function(){}。
但是只要把前后台代码中的访问路径中的validateAccountNonExistent改成validateTelephoneNonExistent就没有问题 =-= 。求解!!!!!
补充
{readyState: 4, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}abort: ƒ (e)always: ƒ ()catch: ƒ (e)done: ƒ ()fail: ƒ ()getAllResponseHeaders: ƒ ()getResponseHeader: ƒ (e)overrideMimeType: ƒ (e)pipe: ƒ ()progress: ƒ ()promise: ƒ (e)readyState: 4responseText: ""setRequestHeader: ƒ (e,t)state: ƒ ()status: 200statusCode: ƒ (e)statusText: "parsererror"then: ƒ (t,r,i)__proto__: Object
VM513:170 parsererror
VM513:171 SyntaxError: Unexpected end of JSON input
at parse (<anonymous>)
at Ut (jquery.min.js:2)
at k (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)
at Object.send (jquery.min.js:2)
at Function.ajax (jquery.min.js:2)
at Object.callback (<anonymous>:153:31)
at Object.call (bootstrapValidator.min.js:10)
at Object.validate (bootstrapValidator.min.js:10)
at b.validateField (bootstrapValidator.min.js:10)