1
路徑有沒有辦法讓URL路徑的第一部分,前/ C:春RequestMapping:獲取用斜槓
完蛋了:/Category1/Subcategory1.1/Subcategory1.1.1/C/{categoryCode:*}
@Controller
@RequestMapping(value = "/**/c")
public class CategoryPageController {
@RequestMapping(value = "/{categoryCode:.*}", method = RequestMethod.GET)
public ModelAndView viewCategory(@PathVariable String categoryCode,
final HttpServletRequest request) {
String categoryPath = ...
我試圖用AntPathMatcher(extractPathWithinPattern),但我不能確定正確的模式。
感謝快速回復。我噴射注入HttpServletRequest,但colling getRequestURL()我檢索完整路徑(http:// ....)我不需要它,我只需要「/ c /」之前的部分爲例:/ Category1 /Subcategory1.1/Subcategory1.1.1/ 關心 – scesnik