当前位置:网站首页>9-WebUtil工具类.md

9-WebUtil工具类.md

2022-08-03 00:34:00 张 邵

WebUtils

package com.zs.utils.web;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class WebUtils
{
    /**
     * 将字符串渲染到客户端
     *
     * @param response 渲染对象
     * @param string 待渲染的字符串
     * @return null
     */
    public static String renderString(HttpServletResponse response, String string) {
        try
        {
            response.setStatus(200);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().print(string);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return null;
    }
}
原网站

版权声明
本文为[张 邵]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44235759/article/details/126106340