获取SpringMVC的映射路径

2021-07-13 13:13

阅读:410

标签:ping   通过   技术   style   pattern   app   ati   alt   dispatch   

技术分享图片
public String init(HttpServletRequest request, HttpServletResponse response){  
    List uList = new ArrayList();//存储所有url集合  
    WebApplicationContext wac = (WebApplicationContext) request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);//获取上下文对象  
    RequestMappingHandlerMapping bean = wac.getBean(RequestMappingHandlerMapping.class);//通过上下文对象获取RequestMappingHandlerMapping实例对象  
    Map handlerMethods = bean.getHandlerMethods();  
    for (RequestMappingInfo rmi : handlerMethods.keySet()) {  
        PatternsRequestCondition prc = rmi.getPatternsCondition();  
        Set patterns = prc.getPatterns();  
        for (String uStr : patterns) {  
            uList.add(uStr);  
        }  
    }  
}  
技术分享图片

 

获取SpringMVC的映射路径

标签:ping   通过   技术   style   pattern   app   ati   alt   dispatch   

原文地址:https://www.cnblogs.com/jpfss/p/9542581.html


评论


亲,登录后才可以留言!