参考 http://cn.voidcc.com/question/p-hdnhwour-ve.html

@RequestMapping(value = "/modules/{moduleBaseName}/**", method = RequestMethod.GET) 
@ResponseBody 
public String moduleStrings(@PathVariable String moduleBaseName, HttpServletRequest request) { 
    final String path = 
      request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE).toString(); 
    final String bestMatchingPattern = 
      request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE).toString(); 

    String arguments = new AntPathMatcher().extractPathWithinPattern(bestMatchingPattern, path); 

    String moduleName; 
    if (null != arguments && !arguments.isEmpty()) { 
     moduleName = moduleBaseName + '/' + arguments; 
    } else { 
     moduleName = moduleBaseName; 
    } 

    return "module name is: " + moduleName; 
} 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2021-06-09
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
猜你喜欢
  • 2021-12-31
  • 2021-07-21
  • 2021-10-06
  • 2021-05-19
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
相关资源
相似解决方案