servlet http异常

yzmm
610 阅读
response.sendError可以自定义当前页面http错误状态,HttpServletResponse定义了常规的HTTP错误状态码。例如给浏览器返回一个403错误:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	response.sendError(HttpServletResponse.SC_FORBIDDEN, "禁止使用GET请求.");
}

HTTP Status 403 - 禁止使用GET请求.


type Status report

message 禁止使用GET请求.

description Access to the specified resource (禁止使用GET请求.) has been forbidden.


Apache Tomcat/7.0.29

评论 (0)

发表评论