Home > Back-end >  How to change the @ RequestMapping (value="/board") of the path to the board, adopt a new
How to change the @ RequestMapping (value="/board") of the path to the board, adopt a new

Time:09-19


How to change the @ RequestMapping (value="https://bbs.csdn.net/board") in the path to the board, the new route calls, is to start, is boad path, but after the start, want to change the url path this do? I wrote a, there are still problems, the value changed, but there's no way to load update,

 @ RestController 
@ RequestMapping ("/test ")
Public class BoardController {

@ RequestMapping (value="https://bbs.csdn.net/board", method={RequestMethod. POST})
Public ApiResult board (@ RequestBody Map Params) throws the Exception {

Return ApiResult. Succ (null);
}
}


 
//get member methods of class object
Method board=BoardController. Class. GetMethod (the "board", the Map. The class);
//get the Test the annotations on
RequestMapping RequestMapping=board. GetAnnotation (RequestMapping. Class);
//get agent processor
InvocationHandler handler=Proxy. GetInvocationHandler (requestMapping);
//the past private memberValues attribute
The Field f=handler. GetClass (). GetDeclaredField (" memberValues ");
F.s etAccessible (true);
//for instance attributes map
Map MemberValues=(Map) F.g et (handler);
//modify attribute values
MemberValues. Put (" value ", "/url");

CodePudding user response:

I want to know more, why do you want to do that

CodePudding user response:

Want to write a generic type damper, the performance pressure test, call the service, each time there is a new demand, just change the inside of the configuration file url and return value parameter is ok, other don't need,,

CodePudding user response:

Then I suggest you use httpcore or netty, baffle its own HTTP service,
While for springmvc merely the start or stop the trigger baffle service interface,
In this way, your own controllable damper service parameters,

CodePudding user response:

Don't change the,,,,

CodePudding user response:

Clue, can use @ PathVariable
In the URL path for the response processing parameters,
If the above solution still cannot satisfy the requirement of the building Lord, then, a custom interceptors, intercepts all requests, from the processing,

CodePudding user response:

refer to the second floor meditation 000 response:
want to write a generic type damper, the performance of pressure test, call the service, each time there is a new demand, just change the inside of the configuration file url and return value parameter is ok, other don't need,,
can register to the nacos, then you want to change the value of a variable, in the configuration file, so that each time change nacos configuration file can be in the center,
  • Related