HttpServletResponse Tool Class

Source: Internet
Author: User

Package Com.gta.yyyf.commons.utils;import Java.io.ioexception;import Javax.servlet.http.HttpServletResponse; Import Org.slf4j.logger;import org.slf4j.loggerfactory;/** * httpservletresponse help?? * * @author * */public Final class Responseutils {public static final Logger Logger = Loggerfactory.getlogger (responseut Ils.class);/** * Send text. Use UTF-8 encoding. * * @param response * HttpServletResponse * @param text * sent string */public static void RenderText (Ht Tpservletresponse response, String text) {Render (response, "Text/plain;charset=utf-8", text);} /** * Send json. Use UTF-8 encoding. * * @param response * HttpServletResponse * @param text * sent string */public static void Renderjson (Ht Tpservletresponse response, String text) {Render (response, "Application/json;charset=utf-8", text);} /** * Send XML. Use UTF-8 encoding. * * @param response * HttpServletResponse * @param text * Send a string */public static void Renderxml (HTT Pservletresponse response, String text) {rendER (response, "Text/xml;charset=utf-8", text);} /** * Send content. Use UTF-8 encoding. * * @param response * @param contentType * @param text */public static void render (HttpServletResponse response, String C Ontenttype,string text) {response.setcontenttype (contentType); Response.setheader ("Pragma", "No-cache"); Response.setheader ("Cache-control", "No-cache"); Response.setdateheader ("Expires", 0); try {response.getwriter (). Write (text); Response.getwriter (). Flush ();} catch (IOException e) {logger.error (E.getmessage (), E);}}}

HttpServletResponse Tool Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.