2016-10-15 198 views
2

我目前有一個存儲庫,註釋爲@RepositoryRestResource。我添加以下內容:彈簧休息資源更改路徑

@RestResource(path="make", rel = "make", description = @Description("Get vehicles by make")) 
List<Vehicle> findByMake(@Param("make") String make); 

這工作得很好,但默認的路徑是api/vehicles/search/make

如何刪除/search零件,並且路徑爲api/vehicles/make

回答

2

不幸的是,這是不可能的。我在Spring Data Rest源代碼中做了一些研究。

有跡象表明,在RepositorySearchController.java爲URI建築使用常量:

private static final String SEARCH = "/search"; 
private static final String BASE_MAPPING = "/{repository}" + SEARCH; 

而且here是,通過服務與@RepositoryRestResource註釋處理請求的操作方法。所以你可以看到search部分是硬編碼的,不能改變。

+0

什麼是Servlet * Filter *? – codesmith