In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to use SpringBoot to get the routing of all interfaces", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use SpringBoot to get routes for all interfaces".
Catalogue
SpringBoot acquires routes for all interfaces
Springboot partial routing takes effect
Problem record
SpringBoot gets the route @ Autowired WebApplicationContext applicationContext; @ RequestMapping of all interfaces (value = "v1/getAllUrl", method = RequestMethod.POST) public Object getAllUrl () {RequestMappingHandlerMapping mapping = applicationContext.getBean (RequestMappingHandlerMapping.class); / / gets the corresponding information of url and class and method Map map = mapping.getHandlerMethods (); / / List urlList = new ArrayList () / / for (RequestMappingInfo info: map.keySet ()) {/ get the Set collection of url. A method may correspond to multiple url// Set patterns = info.getPatternsCondition () .getPatterns (); / for (String url: patterns) {/ / urlList.add (url); / /} / /} List list = new ArrayList () For (Entry m: map.entrySet ()) {Map map1 = new HashMap (); RequestMappingInfo info = m.getKey (); HandlerMethod method = m.getValue (); PatternsRequestCondition p = info.getPatternsCondition (); for (String url: p.getPatterns ()) {map1.put ("url", url) } map1.put ("className", method.getMethod (). GetDeclaringClass (). GetName ()); / / Class name map1.put ("method", method.getMethod (). GetName ()); / / method name RequestMethodsRequestCondition methodsCondition = info.getMethodsCondition () For (RequestMethod requestMethod: methodsCondition.getMethods ()) {map1.put ("type", requestMethod.toString ());} list.add (map1);} Springboot partial routing problem record
The new interface "foo" of the project never takes effect. After investigation, it is found that the basic path "test" is added to @ RequestMaping (value= "test") of the controller layer, and my new interface is annotated as @ PostMappinp ("test/foo). As a result, the generated route is" test/test/foo "and the call address is" test/foo ".
At this point, I believe you have a deeper understanding of "how to use SpringBoot to get the routing of all interfaces". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.