java - JBoss 如何实现 HttpServletResponse setStatus() 与 sendError()

标签 java servlets jboss

据我所知,当您对响应调用 sendError() 方法时,它将关闭响应,但是,如果您使用错误代码(例如 404)调用 setStatus() ,是否也会关闭响应?

最佳答案

No :

If this method is used to set an error code, then the container's error page mechanism will not be triggered. If there is an error and the caller wishes to invoke an error page defined in the web application, then sendError(int, java.lang.String) must be used instead.

关于java - JBoss 如何实现 HttpServletResponse setStatus() 与 sendError(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34998331/

相关文章:

java - 无法找到请求目标的有效证书路径 -> CAS 登录后

java - Java 中 C 的 "static"关键字等同于什么?

java - 读取前刷新/清除 System.in (stdin)

java - 最终网页后运行java程序

eclipse - Eclipse 中的部署目录在哪里?

java - 如何从 HttpClient 切换到 HttpUrlConnection?

java - servlet 无法保存到数据库

java - 在javafx中自动安装自定义字体

java - 异构Java EE集群

java - 在 JBoss 5.1 中的队列中查找 JMS 消息的简单 Web 应用程序