Spring 如何在其方法中访问此端点@GetMapping(";/catalog/**)的url?
我有以下几点:Spring 如何在其方法中访问此端点@GetMapping(";/catalog/**)的url?,spring,spring-boot,endpoint,Spring,Spring Boot,Endpoint,我有以下几点: @GetMapping("/catalog/**") public String getCatalog(final Model model){ // code } 此端点处理以下URL:目录/衣服,目录/衣服/男人,目录/衣服/女人等等。 当我输入该url时: http://localhost:8080/catalog/clothes/women 此端点将被激发。 我需要在方法中获取此url。我该怎么做 提前感谢。第二个代码段看起来不错,没有调用它
@GetMapping("/catalog/**")
public String getCatalog(final Model model){
// code
}
此端点处理以下URL:目录/衣服,目录/衣服/男人,目录/衣服/女人等等。
当我输入该url时:
http://localhost:8080/catalog/clothes/women
此端点将被激发。
我需要在方法中获取此url。我该怎么做
提前感谢。第二个代码段看起来不错,没有调用它的问题似乎在其他代码中,或者共享类/配置代码
@Controller
public class CatalogController {
private static final Logger logger = LoggerFactory.getLogger(CatalogController.class);
@GetMapping("/catalog/**")
public String getCatalog(final Model model, HttpServletRequest request, HttpServletResponse response){
logger.debug(request.getRequestURL().toString());
logger.debug(request.getQueryString());
logger.debug("Inside catalog");
return null;
}
}
如果您输入的URL类似于-http://localhost:8080/catalog/a/b/c/d?key=value
上述代码将记录:
- http://localhost:8080/catalog/a/b/c/d (网址)
- 键=值(查询字符串)