过滤器输出返回值

Posted ynhk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了过滤器输出返回值相关的知识,希望对你有一定的参考价值。

 

 

    private void returnJson(HttpServletRequest request,ServletResponse response, ResultModel ResultModel) throws IOException 
        //把返回值输出到客户端
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
        httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
        httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
        httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
        response.setContentType("application/json; charset=utf-8");
        response.setCharacterEncoding("UTF-8");
        ServletOutputStream outputStream = response.getOutputStream();
        outputStream.write(JsonTools.objToJson(ResultModel).getBytes());
        outputStream.flush();
        outputStream.close();

    

 

以上是关于过滤器输出返回值的主要内容,如果未能解决你的问题,请参考以下文章

使用过滤器返回对象中的属性值

Qt 事件处理和事件过滤器的返回值

查询过滤器确实在我的 s-s-rS 报告中返回过滤值

python CNN一个过滤器套用在一图片对应区域的输出值

Java过滤器不能返回布尔值[重复]。

AWS CLI过滤器OR逻辑