Shiro Learning Series Tutorial 4: Integrating the Web (2)

The main content of this lecture:

1: Shiro can use wildcards to match access URLs

2: The use of shiro tags

3: Mechanism of shiro session

URL matching method:

Demo:

Now the path configured by shiro.ini is:

 

 

Direct access to /admin

 

 

Ok. No problem.

So what if we visit /admin1?

 

 

Not anymore.

Modify the shiro.ini configuration file.

 

 

After restarting, accessing /admin1 again will block the login page.

 

 

Use of Shiro tags

 

 

Demo:

When using the shiro tag, you need to introduce a tag library that supports the shiro tag on the corresponding page:,

When the user has the admin role, the success.jsp page displays [Welcome to the user with the admin role to log in! ! ] If the user is not in the admin role, it will display [Welcome to login]

Process on the page:

 

 

After login with non-admin role (xiaotang=123456):

 

 

After logging in with the admin role (kaigejava=123456)

 

 

Demo two:

After logging in with the user xiaotang=123456:

 

 

Displaying user identity information:

As shown below:

 

 

Shiro's session mechanism

The Shiro session mechanism can use the session mechanism of the servlet.

It is also possible to use shiro's own session mechanism.

 

 

 

 

 

 

ps:

related suggestion:

Shiro Tutorial 1 Shiro's helloworld

Shiro Learning Series Tutorial 2: Obtaining Authentication Information from the Database

Shiro Learning Series Three: Integrating the Web

If this article is helpful to you, please forward it while collecting it. Thanks!

Pay attention to [Kai Ge java]

Welcome to the public account of Kaige: Kaige Java

Welcome to Kaige's personal website: www.kaigejava.com

The original address of this article: http://www.kaigejava.com/article/detail/ 46

Related tutorials in this series:

Shiro Tutorial 1 Shiro's helloworld

Shiro Learning Series Tutorial 2: Obtaining Authentication Information from the Database

Shiro Learning Series Three: Integrating the Web

Shiro Learning Series Tutorial 4: Integrating the Web (2)

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326690510&siteId=291194637