[英]Spring rest resource change path
I currently have a repository annotated with @RepositoryRestResource
.我目前有一个用
@RepositoryRestResource
注释的存储库。 I'm adding the following:我正在添加以下内容:
@RestResource(path="make", rel = "make", description = @Description("Get vehicles by make"))
List<Vehicle> findByMake(@Param("make") String make);
This works fine but the path by default is api/vehicles/search/make
.这工作正常,但默认路径是
api/vehicles/search/make
。
How can I remove the /search
part and just have the path be api/vehicles/make
?如何删除
/search
部分并让路径为api/vehicles/make
?
Unfortunately it's not possible.不幸的是,这是不可能的。 I make some research in Spring Data Rest source code.
我对 Spring Data Rest 源代码做了一些研究。
There are constants that uses for URI building in RepositorySearchController.java
:在
RepositorySearchController.java
有用于 URI 构建的常量:
private static final String SEARCH = "/search";
private static final String BASE_MAPPING = "/{repository}" + SEARCH;
And here is the action method that handle requests by services with @RepositoryRestResource
annotation. 这是使用
@RepositoryRestResource
注释处理服务请求的操作方法。 So as you can see the search
part is hardcoded and couldn't be changed.如您所见,
search
部分是硬编码的,无法更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.