Spring rest resource change path(Spring rest 资源变更路径)
问题描述
我目前有一个使用 @RepositoryRestResource
注释的存储库.我正在添加以下内容:
I currently have a repository annotated with @RepositoryRestResource
. I'm adding the following:
@RestResource(path="make", rel = "make", description = @Description("Get vehicles by make"))
List<Vehicle> findByMake(@Param("make") String make);
这工作正常,但默认路径是 api/vehicles/search/make
.
This works fine but the path by default is api/vehicles/search/make
.
我怎样才能删除 /search
部分,只让路径是 api/vehicles/make
?
How can I remove the /search
part and just have the path be api/vehicles/make
?
推荐答案
很遗憾,这是不可能的.我对 Spring Data Rest 源代码进行了一些研究.
Unfortunately it's not possible. I make some research in Spring Data Rest source code.
在 RepositorySearchController.java
:
private static final String SEARCH = "/search";
private static final String BASE_MAPPING = "/{repository}" + SEARCH;
和here 是使用 @RepositoryRestResource
处理服务请求的操作方法注解.如您所见,search
部分是硬编码的,无法更改.
And here is the action method that handle requests by services with @RepositoryRestResource
annotation. So as you can see the search
part is hardcoded and couldn't be changed.
这篇关于Spring rest 资源变更路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Spring rest 资源变更路径
基础教程推荐
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01