做接口的拦截器时,需在拦截器中通过response返回JSON信息
response
.setCharacterEncoding( "UTF-8");
response
.setContentType( "application/json; charset=utf-8");
PrintWriter out
= null
;
try{
JSONObject res
= new JSONObject();
res
.put( "status", "error");
res
.put( "msg", "vin号错误,大于18位");
out
= response
.getWriter();
out
.append(res
.toString());
return false;
}
catch (Exception e
){
e
.printStackTrace();
response
.sendError( 500);
return false;
}
转载请注明原文地址: https://lol.8miu.com/read-34659.html