As stated, the reason I'm having the above-mentioned problems are:
Coding should be set in the acquisition PrintWriter before
resp.setCharacterEncoding("utf-8");
resp.setContentType("application/json;charset=utf-8");
PrintWriter out = resp.getWriter();
// HTTP 错误 401.1 - 未经授权:访问由于凭据无效被拒绝。
resp.setStatus(401);