First import the Druid package, and then configure the Configplugin
1 @Override2 Public voidConfigplugin (Plugins me) {3 /**Configuring the Druid Data Connection pool plug-in **/4Druidplugin dp=NewDruidplugin (GetProperty ("Jdbcurl"), GetProperty ("user"), GetProperty ("Password"). Trim ());5 /**Configuring Druid Monitoring **/6Dp.addfilter (NewStatfilter ());7Wallfilter wall=NewWallfilter ();8Wall.setdbtype ("MySQL");9 dp.addfilter (wall);Ten Me.add (DP); One AActiverecordplugin ARP =NewActiverecordplugin (DP); - Me.add (ARP); -Arp.setshowsql (true); theArp.addmapping ("User", user.class); -}
Second, configure the handle
1 @Override2 Public voidConfighandler (Handlers me) {3Druidstatviewhandler dvh=NewDruidstatviewhandler ("/druid",NewIdruidstatviewauth () {4 Public Booleanispermitted (HttpServletRequest request) {5 //this is simply to determine whether the visitor is logged in, but also to do more granular permissions control6User user= (user) Request.getsession (). getattribute ("User");7 if(user==NULL){8 return false;9 }Ten return"Admin". Equals (User.getstr ("uname")); One } A }); - Me.add (DVH); -}
This way, you can just enter the Localhost/druid. This setting can be viewed only after admin login.
Use Druid in Jfinal and configure View permissions