All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dagm.devtool.utils.ResponseUtils Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2020 maoyan.com
 * All rights reserved.
 *
 */
package com.dagm.devtool.utils;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.dagm.devtool.res.BaseResult;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Guimu
 * @date 2020/02/15
 */
public class ResponseUtils {

    public static void littleAuthor(HttpServletResponse response, String errorMsg)
        throws IOException {
        response.setContentType("application/json; charset=utf-8");
        PrintWriter writer = response.getWriter();
        BaseResult bwJsonResult = BaseResult.generateFailureResult(errorMsg);
        writer.print(JSONObject.toJSONString(bwJsonResult, SerializerFeature.WriteMapNullValue,
            SerializerFeature.WriteDateUseDateFormat));
        response.flushBuffer();
        writer.close();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy