Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Common method | description |
---|---|
addHeader(String name, String value) | Add the specified key value in response to the header information |
containsHeader(String name) | Determining whether a header of the response is provided |
encodeURL(String url) | Encoding specified URL |
sendError(int sc) | Transmitting a specified error status code to the client |
setHeader(String name, String value) | Value specified in the response header |
setStatus(int sc) | In response to the current setting state |
setContentType(String ContentType) | Set the MIME type of the response |
getWriter() | Gets the output stream of characters |
getOutputStream() | Obtain an output byte stream |
System.out.println("I am successful");
//add header info
// 添加头信息
response.addHeader("aaa","bbb");
System.out.println(response.containsHeader("aaa"));
// response.sendError(404);
response.setHeader("aaa","ccc");
// response.setStatus(404);
response.setContentType("text/html;charset=utf-8");
// response.getWriter().write("剑徒之路");
response.getOutputStream().write("青空一鸦".getBytes());
// getWriter()和getOutputStream()不能同时使用