禁止tomcat 目录浏览以及设置友好错误页面

 

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值