web.xml中加入
<servlet> <servlet-name>DruidStatView</servlet-name> <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class> <init-param> <!-- 不允许清空统计数据 --> <param-name>resetEnable</param-name> <param-value>false</param-value> </init-param> <init-param> <!-- 用户名 --> <param-name>loginUsername</param-name> <param-value>Steven</param-value> </init-param> <init-param> <!-- 密码 --> <param-name>loginPassword</param-name> <param-value>s123</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DruidStatView</servlet-name> <url-pattern>/druid/*</url-pattern> </servlet-mapping>
配置好后访问
http://$(服务器ip):8080/${项目名}/druid/login.html
eg: http://localhost:8080/BS/druid/login.html
若没有设置拦截,也可以直接访问后台的监控页面