运行springboot Application后:
输入网址打开对应的static下的页面,ajax举例(推荐mui,如果是jQuery还得解决跨域):
mui.post(serverAddress + 'faceMatch', {
imgBase64String: imgBase64String
}, function(userNameJSONObject) {
var userName = userNameJSONObject.userName;
if(userName != null){
alert("员工为:" + userName);
} else {
alert('未检测到匹配管理库中的人脸!');
}
}, 'json');
注意,如果controller中的对应接口直接返回纯String(如员工姓名),那么dataType应该为text,否则就收不到响应,如果想dataType为json,那么对应接口应该返回实体类或者Json字符串。dataType和接口返回不匹配,会导致即使接口正常运行到return,也拿不到返回结果。