繁体   English   中英

Spring Mvc Dynamic RequestMapping

[英]Spring Mvc Dynamic RequestMapping

我的问题是控制器上的动态网址。我有类别树。我的类别有n个子类别。

我的网址:www.xyz.com/category/mainCategory/subCategory/subCategory/subCategory/subCategory

@Controller
@RequestMapping(value="/category/**")
public class CategoryController {

    ????     
    public void init()

}

我如何定义动态请求映射?

您也可以尝试以下方法:

@RequestMapping(value="/category/{path}/**", method = RequestMethod.GET)
public void categoryTest(@PathVariable("path") String path, HttpServletRequest request) throws Exception {
    String remainingPaths = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    logger.debug("path = " + path + "/" + remainingPaths);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM