当前位置:网站首页>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


边栏推荐
- org.yaml.snakeyaml.scanner. ScannerException: mapping values are not allowed here in ‘reader‘, line
- 第二部分—C语言提高篇_9. 链表
- [C language] array
- 力扣155题,最小栈
- Vector execution engine framework gluten announced the official open source and appeared at spark technology summit
- 买不到的数目
- [interview: concurrency 26: multithreading: two-phase termination mode] volatile version
- [H5 bottom scrolling paging loading]
- 文件上传到服务器
- [Luogu] p2341 popular cattle
猜你喜欢

Re understand the life world and ourselves

Pytorch学习记录(二):张量

第二部分—C语言提高篇_11. 预处理

Add an article ----- scanf usage

Dynamic memory management and related topics

Download win10 system image and create virtual machine on VMware virtual machine

第二部分—C语言提高篇_13. 递归函数

18、打开、保存文件对话框使用小记

文件上传到OSS文件服务器

The place where the dream begins ---- first knowing C language (2)
随机推荐
Product principles of non-financial decentralized application
[shader realizes swaying effect _shader effect Chapter 4]
[interview: concurrency 26: multithreading: two-phase termination mode] volatile version
1. Configuration environment and project creation
Positioning of soaring problems caused by online MySQL CPU
[C language] array
np. transpose & np.expand_ dims
证券公司哪家佣金最低?网上开户安全吗
Simple SQL optimization
An online accident, I suddenly realized the essence of asynchrony
Typescript notes
Silicon Valley class lesson 7 - Tencent cloud on demand management module (2)
pgsql -> flink cdc -> flink -> Mysql, if a PgSQL CDC
[step by step, even thousands of miles] key words in the specified time period of the statistical log
Pre research of data quality management tools Griffin vs deequ vs great expectations vs quality
30、 Modern storage system (management database and distributed storage system)
Question 152: product maximum subarray
18、打开、保存文件对话框使用小记
2022.7.18-----leetcode.749
Force deduction 155 questions, minimum stack