In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the SpringMVC interceptor how to set multiple path, the article is very detailed, has a certain reference value, interested friends must read it!
Pit in the path path of the SpringMVC interceptor
SpringMVC provides a convenient interceptor for our development. The path is intercepted by configuration in the configuration file, but this path has a small hole when it is configured.
We all know that the / * * in the SpringMVC interceptor is to configure all paths. Now I have a requirement to intercept requests that start with / user/. My path is written as / user/**, so that I can intercept all requests for symbolic conditions.
Then my project requirements increased. I added multiple permissions to the project and wanted to use interceptors to control it. Suppose there is a feature that is only available to administrators, so I set its access path to / user/manager/xxxx/xxxx. So I added another interceptor to intercept all requests with / manager/ in the path. I wrote path as / manager/'**, but it didn't work.
User's interceptor works, but manager's interceptor doesn't work. I thought there was something wrong with the interceptor. Then after checking all afternoon, I found that when I changed the path to / manager/user/xxxx/xxxx, the manager interceptor worked but the user interceptor didn't work. I'm sure there's something wrong with path.
After repeated modification attempts, I understand that / user/** only applies to requests that start with / user/, and there can be nothing in front of / user/. Since all my requests start with / user/, user interceptors always work properly, but manager interceptors are different. My path is written as / manager/**, but all my requests with / manager/ are preceded by / user/. So this does not satisfy the / manager/**. in the path path When you want to add another name to the name, you need / * / manager/**,. If there is more than one name, it is / * * / manager/**,. Of course, because / * * is a wildcard, url that begins with manager also meets this condition.
SpringMVC interceptor sets multiple path sets multiple path
If you want to specify multiple path for the same interceptor, you can add more than one in sequence:
Edit add above is all the content of the article "how to set up multiple path in SpringMVC interceptor". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.