In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-10-26 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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.