springmvc获取所有链接信息-创新互联
springmvc获取所有链接信息
预期结果:
/auth/groups/save_menu 保存组的菜单
/auth/menus/add 添加菜单
/auth/menus 获取菜单列表
/auth/menus/delete 删除菜单
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获取所有链接信息-创新互联
网页URL:http://scjbc.cn/article/djsdcj.html