Use Druid in Jfinal and configure View permissions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.