package com.mes.utils;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import org.springframework.http.HttpStatus;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
|
/**
|
* @Author : zhoush
|
* @Date: 2024/4/8 15:46
|
* @Description:
|
*/
|
public class ResponseUtil {
|
|
public static final String APPLICATION_JSON_UTF8_VALUE = "application/json;charset=UTF-8";
|
|
public static void out(HttpServletResponse response, Result r) {
|
ObjectMapper mapper = new ObjectMapper();
|
response.setStatus(HttpStatus.OK.value());
|
response.setContentType(APPLICATION_JSON_UTF8_VALUE);
|
try {
|
mapper.writeValue(response.getWriter(), r);
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|