在web.xml中添加如下代码
<!-- druid监控 --> <servlet> <servlet-name>DruidStatView</servlet-name> <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class> <!-- deny优先于allow,如果在deny列表中,就算在allow列表中,也会被拒绝。 如果allow没有配置或者为空,则允许所有访问 --> <init-param> <param-name>allow</param-name> <param-value>10.12.5.170/16,127.0.0.1</param-value> </init-param> <init-param> <param-name>deny</param-name> <param-value>10.12.5.170</param-value> </init-param> <!-- 在StatViewSerlvet输出的html页面中,有一个功能是Reset All,执行这个操作之后,会导致所有计数器清零,重新计数 --> <init-param> <param-name>resetEnable</param-name> <param-value>false</param-value> </init-param> <!-- 用户名和密码 --> <init-param> <param-name>loginUsername</param-name> <param-value>druid</param-value> </init-param> <init-param> <param-name>loginPassword</param-name> <param-value>druid</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DruidStatView</servlet-name> <url-pattern>/druid/*</url-pattern> </servlet-mapping>