@PathVariable 包含斜杠

@RequestMapping(value = "/{collectionName}/products/**")
public String productDetail(Model model,HttpServletRequest request, @PathVariable String collectionName) {

@PathVariable的值包含斜杠,如:/collections/Cleansers/products/A/B

用正则替换不需要的字符串

request.getServletPath().replaceAll("^/collections?[-\w.\s\/]+/products/","")


你可能感兴趣的:(@PathVariable 包含斜杠)