当前位置:网站首页>Chapter 1 Introduction and use skills of interceptors
Chapter 1 Introduction and use skills of interceptors
2022-07-26 23:51:00 【Sleepy sheep】
1-1 Interceptor Getting started with interceptors



Demonstrate one by one
Create a project

take restful Copy the code from , Easy to demonstrate
open xml Increased reliance on

provided Only in the development and compilation will reference , When packaging for final use jar Will be excluded
Add interceptor package


Generate three methods



Why introduce the dependency just now ?
because

These three methods all point to native request and response object , If you do not introduce dependent programs, you will report compilation errors

return true It will be delivered to the later interceptor or controller ,false It will directly return to the client , The result determines whether to continue execution or end immediately and return the response back , This is very important for program control

After the target resource is processed successfully , But before the response text is generated , What to do
![]()

After the corresponding text of the target is generated , That's how it works
![]()

stay applicationContext Configure in to make springmvc To identify

Intercept all requests , Then the intercepted request is delivered to Myinterceptor And execute it in the sequence of the implementation methods inside
function

The response returns success , View console

This sentence is increasing

![]()
1-2 Interceptor Using skills

There will be many problems to be solved in actual use
start-up

But the controller prints out a lot of extra information

Every time you send localhost This url Its essence is through tomcat To call springmvc The parsing function of , To get the corresponding resources , These resources are in line with /** All rules will be blocked
![]()
The interceptor is not affected by this sentence

Exclude some static addresses
Run again 
At this time, only client.html Captured
There are too many static types , If you configure one by one like the above, it may be a long time , How to make us understand static resources and controller Applications are effectively differentiated ?
Unified management of static resources

By managing the static resource directory to uniformly exclude these
![]()
Reverse thinking is also possible, such as only restful Intercept all requests under
![]()
![]()
If more than one is needed uri Where to intercept , Additional writing
![]()
If a request is filtered by multiple interceptors at the same time , Which one is the first to execute ?
increase myinterceptor1

Configure the new interceptor

Two interceptors work uri It's the same , That's first ? What about execution later ?、

The order is reversed , Why? ?

return false What happens when an interrupt occurs ?


The request that should be executed and subsequent processing are all blocked , At the same time, the response is all produced in the current method
Pass in an array to test


What you get in the corresponding part of the request is the response text generated in the interceptor
1-3 Inteceptor and Filter The difference between


边栏推荐
- [shader realizes swaying effect _shader effect Chapter 4]
- Question 152: product maximum subarray
- An online accident, I suddenly realized the essence of asynchrony
- NFT展示指南:如何展示你的NFT藏品
- New features of ES6
- 【2016】【论文笔记】差频可调谐THz技术——
- Baidu website Collection
- Three person management of system design
- 买不到的数目
- Add an article ----- scanf usage
猜你喜欢

Machine learning notes - building recommendation system (3) six research directions of deep recommendation system

Part II - C language improvement_ 9. Linked list

Bid farewell to wide tables and achieve a new generation of Bi with DQL
![[2016] [paper notes] differential frequency tunable THz technology——](/img/7e/71126950250997fc436a4ee730aee7.png)
[2016] [paper notes] differential frequency tunable THz technology——

第二部分—C语言提高篇_6. 多维数组

Dajiang Zhitu and CC have produced multiple copies of data. How to combine them into one and load them in the new earth map

带你熟悉云网络的“电话簿”:DNS

Baidu website Collection

04-传统的Synchronized锁

Silicon Valley class lesson 6 - Tencent cloud on demand management module (I)
随机推荐
29、 Implementation of xv6 file system (GDB tracks mkfs, buffer cache and log)
[shader realizes shine effect _shader effect Chapter 3]
MVC three-tier architecture
What are the use cases in the Internet of things industry in 2022?
Part II - C language improvement_ 8. File operation
[shaders realize distorted outline effect _shader effect Chapter 2]
org.yaml.snakeyaml.scanner. ScannerException: mapping values are not allowed here in ‘reader‘, line
Azure synapse analytics Performance Optimization Guide (4) -- optimize performance using result set caching
In simple terms, cchart daily lesson - happy high school lesson 57 new starting point, the old tree and new bud of colorful interface library
Kingbasees database administrator's Guide -- 11 manage data files and temporary files
【C语言】数组
Go uses flag package to parse command line parameters
Question 141 of Li Kou: circular linked list
Part II - C language improvement_ 10. Function pointer and callback function
第二部分—C语言提高篇_6. 多维数组
2022.7.26-----leetcode.1206
Real time voice quality monitoring
An online accident, I suddenly realized the essence of asynchrony
When aw9523b chip is used to drive 16 channel led, the LED is wrongly lit
Six challenges facing enterprise data governance!