Home > Back-end >  SpringBoot request intercept forward again
SpringBoot request intercept forward again

Time:12-07

General situation is visit http://localhost:8999/getServerMsg, sends a request directly to the Controller service interface, processing,

Now, there is a demand, requests may be directly to the corresponding interface processing, also may be directly forwarded to other service processing (such as forwarded to http://192.168.1.108:8080/msg/get). How to do with the best? In the request to the corresponding interface handle, or on the upper deck of the into the corresponding Controller interface to deal with? Is there any way to achieve the request to intercept processing first, and then forwards the request to an external system or directly into the corresponding Controller interface request execution?
Trouble you help

CodePudding user response:

reference
https://www.cnblogs.com/lwdmaib/p/9429214.html



@ RequestMapping (value="https://bbs.csdn.net/save")
Public String the save () {
The return of "redirect: update? Name=zhangsan& Age=23 ";
}

Or

@ RequestMapping (value="https://bbs.csdn.net/login")
Public String login (String name, String password, RedirectAttributes model) {

Model. AddFlashAttribute (" MSG ", name);

The return of "redirect: tohome";
}

CodePudding user response:

See springcloud gateway gateway to use, the feeling is right for you

CodePudding user response:

With interceptors to intercept the request, forwarded to the handling and processing is completed on the request not to go?? Intercept condition after processing is not have??

For example: I want to enter the center of personal, interceptors to intercept whether I login, not log in to the login screen, after the login is not intercept

Is that so??

CodePudding user response:

reference 3 floor with 灬 shadow reply:
with interceptors to intercept the request, forwarded to the handling and processing is completed on the request not to go?? Intercept condition after processing is not have??

For example: I want to enter the center of personal, interceptors to intercept whether I login, not log in to the login screen, after the login is not intercept

Is that so??
where the intercept intercept? Judgment is to enter the Controller then?

CodePudding user response:

references 4 floor LuckyJiang. 2019 response:
Quote: refer to the third floor with 灬 shadow response:

With interceptors to intercept the request, forwarded to the handling and processing is completed on the request not to go?? Intercept condition after processing is not have??

For example: I want to enter the center of personal, interceptors to intercept whether I login, not log in to the login screen, after the login is not intercept

Is that so??
where the intercept intercept? Judgment is to enter the Controller then?

Before you request a Controller to intercept judge whether meet the conditions, does not meet the conditions of interception, meet the conditions to get into the Controller (not intercept)

CodePudding user response:

references 4 floor LuckyJiang. 2019 response:
Quote: refer to the third floor with 灬 shadow response:

With interceptors to intercept the request, forwarded to the handling and processing is completed on the request not to go?? Intercept condition after processing is not have??

For example: I want to enter the center of personal, interceptors to intercept whether I login, not log in to the login screen, after the login is not intercept

Is that so??
where the intercept intercept? Judgment is to enter the Controller then?

You baidu springboot blocker, oneself try to know

CodePudding user response:

Using interceptor intercepts all requests, if through your business needs will release (find your corresponding interface), if not through your business needs, so, you are in processing

CodePudding user response:

First projects to the service layer and controller layer, specific business service layer, controller layer defines the interface, and then refer to the service layer nursing methods of the business, the

Don't use intercepting well,

At most use transaction

CodePudding user response:

Can after enter a blocker, judgment, into another interceptor

CodePudding user response:

I also have this demand now, turn to the gateway receives the request
  • Related