HttpServletResponse类用于封装Http响应消息
void setHeader( String name,String value )
参数:
String name:字段名称
String value:值
返回值:void
返回值意义:无
作用:设置响应头
void setContentType(String type)
参数:
String type:输出内容的类型
返回值:void
返回值意义:无
作用:设置响应体的类型,同时可以设置字符集编码(text/html;charset=utf-8)
void setCharacterEncoding(String charset)
参数:
String charset:响应体的字符集编码
返回值:void
返回值意义:无
作用:设置响应体的字符集编码
ServletOutputStream getOutputStream()
参数:无
返回值:ServletOutputStream对象
返回值意义:返回输出流对象
作用:获取输出流对象,可以向客户端输出二进制数据
PrintWriter getWriter()
参数:无
返回值:PrintWriter对象
返回值意义:返回字符输出流对象
作用:返回可将字符文本发送到客户端的 PrintWriter
对象
printWriter.wrinte(String s):即可发送
原文:https://www.cnblogs.com/remix777/p/15123152.html