禁止tomcat 目录浏览以及设置友好错误页面
2012-02-29 07:59
316 查看
1、禁止tomcat目录浏览,将listings设为false
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2、配置web.xml
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
3、http error codes 参考
HTTP Error Codes and what they mean
Web servers will use the following Error Codes when something goes awry. Knowing what they mean enables you to fix the problem, or create custom error pages.
The status codes are returned to the client the request (typically an Internet Browser) and also recorded in the server's log file. Theses error codes are encoded into decimal ranges:
Error Code Range Type of Error Code
Error Code Range Type of Error Code
100 to 199 Informational status codes, rarely used - and generally only written to server logs.
200 to 299 Successful, only 200 frequently used - and generally only written to server logs.
300 to 399 Warning - but the request may still be satisfiable.
400 to 499 Client Error, the request was invalid in some way.
500 to 599 Server Error, the server could not fulfil the (valid) request.
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>
org.apache.catalina.servlets.DefaultServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2、配置web.xml
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error.jsp</location>
</error-page>
3、http error codes 参考
HTTP Error Codes and what they mean
Web servers will use the following Error Codes when something goes awry. Knowing what they mean enables you to fix the problem, or create custom error pages.
The status codes are returned to the client the request (typically an Internet Browser) and also recorded in the server's log file. Theses error codes are encoded into decimal ranges:
Error Code Range Type of Error Code
Error Code Range Type of Error Code
100 to 199 Informational status codes, rarely used - and generally only written to server logs.
200 to 299 Successful, only 200 frequently used - and generally only written to server logs.
300 to 399 Warning - but the request may still be satisfiable.
400 to 499 Client Error, the request was invalid in some way.
500 to 599 Server Error, the server could not fulfil the (valid) request.
相关文章推荐
- IDEA中Tomcat相关——如无法访问localhost:8080欢迎页面,无法配置web.xml以及server.xml,设置download.xml下载目录无效等问题
- Tomcat 修改默认端口 以及Tomcat设置虚拟目录
- Tomcat禁止目录浏览
- Tomcat 设置自定义的 404 错误页面
- tomcat下建虚拟目录以及在tomcat首页页面中显示根目录下的文件列表
- Tomcat中禁止浏览目录
- windows7下系统保护中出现错误“文件名、目录名或卷标语法不正确。(0x8007007B)“ 以及保护设置列表中出现“Windows7_os(c:)(找不到)”选项时的解决方法
- tomcat 错误页面设置
- Tomcat6.0内存设置和端口号修改、以及Myeclipse出现OutOfMemoryError:PermGen space错误
- web应用设置统一友好错误页面,处理404,500等错误
- IIS中遇到无法预览的问题(HTTP 错误 401.3 - Unauthorized 由于 Web 服务器上此资源的访问控制列表(ACL)配置或加密设置,您无权查看此目录或页面。)
- 当浏览不存在的页面时,系统会报404错误,返回的404错误不友好,如何自定义与中不同的404页面?
- HTTP 错误 401.3 - Unauthorized 由于 Web 服务器上此资源的访问控制列表(ACL)配置或加密设置,您无权查看此目录或页面。
- ViewPager禁止滑动,设置页片间距,设置当前显示的页面,缓存个数,以及解决嵌套ViewPager左右滑动冲突问题
- Tomcat 404 错误页面的设置
- tomcat 虚拟目录和目录浏览设置
- Tomcat,Jboss禁止目录浏览
- 关于Tomcat的点点滴滴(体系架构、处理http请求的过程、安装和配置、目录结构、设置压缩和对中文文件名的支持、以及Catalina这个名字的由来……等)
- tomcat下建虚拟目录以及在tomcat首页页面中显示根目录下的文件列表
- Nginx设置目录浏览(autoindex)、以及登录权限认证