Skip to content

Commit 40102b2

Browse files
committed
修改返回json字符串的格式化方式为fastJson
1 parent 2947361 commit 40102b2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

api-boot-project/api-boot-plugins/api-boot-plugin-security/src/main/java/org/minbox/framework/api/boot/plugin/security/handler/ApiBootDefaultAccessDeniedHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.minbox.framework.api.boot.plugin.security.handler;
22

3-
import org.codehaus.jackson.map.ObjectMapper;
3+
import com.alibaba.fastjson.JSON;
44
import org.minbox.framework.api.boot.common.model.ApiBootResult;
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
@@ -35,11 +35,11 @@ public class ApiBootDefaultAccessDeniedHandler implements AccessDeniedHandler {
3535
@Override
3636
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
3737
logger.error("ApiBoot Default AccessDeniedHandler.", e);
38-
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
38+
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
3939
response.setStatus(HttpStatus.OK.value());
4040
// ApiBoot Result
4141
ApiBootResult result = ApiBootResult.builder().errorMessage(HttpStatus.FORBIDDEN.getReasonPhrase()).errorCode(String.valueOf(HttpStatus.FORBIDDEN.value())).build();
4242
// return json
43-
response.getWriter().write(new ObjectMapper().writeValueAsString(result));
43+
response.getWriter().write(JSON.toJSONString(result));
4444
}
4545
}

api-boot-project/api-boot-plugins/api-boot-plugin-security/src/main/java/org/minbox/framework/api/boot/plugin/security/point/ApiBootDefaultAuthenticationEntryPoint.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.minbox.framework.api.boot.plugin.security.point;
22

3-
import org.codehaus.jackson.map.ObjectMapper;
3+
import com.alibaba.fastjson.JSON;
44
import org.minbox.framework.api.boot.common.model.ApiBootResult;
55
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
@@ -32,11 +32,11 @@ public class ApiBootDefaultAuthenticationEntryPoint implements AuthenticationEnt
3232
@Override
3333
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
3434
logger.error("Unauthorized", e);
35-
response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
35+
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
3636
response.setStatus(HttpStatus.FORBIDDEN.value());
3737
// ApiBoot Result
3838
ApiBootResult result = ApiBootResult.builder().errorMessage(HttpStatus.UNAUTHORIZED.getReasonPhrase()).errorCode(String.valueOf(HttpStatus.UNAUTHORIZED.value())).build();
3939
// return json
40-
response.getWriter().write(new ObjectMapper().writeValueAsString(result));
40+
response.getWriter().write(JSON.toJSONString(result));
4141
}
4242
}

0 commit comments

Comments
 (0)