您的位置:首页 > 运维架构 > Tomcat

禁止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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐