使用setStatus设置响应状态码,在tomcat上运行页面是空白,代码如下:求解

2024-11-08 08:47:10
推荐回答(1个)
回答1:

void setStatus(int sc)
Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there is an error, and the caller wishes to invoke an error-page defined in the web application, the sendError method should be used instead.
The container clears the buffer and sets the Location header, preserving cookies and other headers.
Parameters:
sc - the status code
tomcat上文档,链接http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletResponse.html#setStatus(int)