how to configure spring-data-rest search method path with @PathVariable

前端 未结 2 1367
遇见更好的自我
遇见更好的自我 2021-01-15 22:18

I want to customize my spring-data-rest search method path by passing parameter as a path variable like follows

http://localhost:8080/orders/search/customers         


        
2条回答
  •  抹茶落季
    2021-01-15 22:48

    Use HttpServletRequest to get the request url:

    findByCustomer(@PathVariable("customerId") Integer customer, HttpServletRequest request){
        String request = request.getRequestURL().toString(); // StringBuffer, so use append if you want to...
        [...]
    }
    

    also you can use request.getQueryString() to get the query part after ?.

提交回复
热议问题