springmvc获取所有链接信息-创新互联

springmvc获取所有链接信息

预期结果:
/auth/groups/save_menu 保存组的菜单
/auth/menus/add 添加菜单
/auth/menus 获取菜单列表
/auth/menus/delete 删除菜单

成都创新互联公司网站建设服务商,为中小企业提供成都网站设计、成都网站建设服务,网站设计,绵阳服务器托管等一站式综合服务型公司,专业打造企业形象网站,让您在众多竞争对手中脱颖而出成都创新互联公司。代码:springmvc获取所有链接信
息
public class AuthorityInitializer {
	@Autowired
    private RequestMappingHandlerMapping handlerMapping;
	@Autowired
	private AuthService authService;
	
	public void init(){
		Map map = handlerMapping.getHandlerMethods();
        Set mappings = map.keySet();


        for(RequestMappingInfo info : mappings) {

        	Set patternSet = new HashSet();
           
        	PatternsRequestCondition condition = info.getPatternsCondition();
            for (String pattern : condition.getPatterns()) {
            	if(StringUtils.endsWith(pattern, "/")){
            		patternSet.add(pattern.substring(0, pattern.length()-1));
            	}else{
            		patternSet.add(pattern);
            	}
			}
            
            for (String patt : patternSet) {
            	String value = patt;
                String name = info.getName();
            	if(StringUtils.isBlank(name) ){
            		name = value;
            	}
            	//保存
            	authService.saveAuthority(value, name);
			}
        }        
	}	
}

spring配置:



本文题目:springmvc获取所有链接信息-创新互联
标题网址:http://pwwzsj.com/article/djsdcj.html