我使用了spring-data-rest,并使用了PUT /{repository}/{id}/{property}这样的请求
Body:
/12
Accept: application/json
Content-Type: text/uri-list
If-Match: 42 (incorrect value)我希望得到412错误,但返回204。
当我调试时,我发现DispatcherServlet使用HandlerExecutionChain with [org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController#createPropertyReference(RootResourceInformation, HttpMethod, CollectionModel, Serializable, String)] and 3 interceptors,该方法不检查if-match值。
并且只有像PUT,PATCH,DELETE这样的请求才会使用HandlerExecutionChain with [org.springframework.data.rest.webmvc.RepositoryEntityController#patchItemResource(RootResourceInformation, PersistentEntityResource, Serializable, PersistentEntityResourceAssembler, ETag, String)] and 3 interceptors来检查if-match值。
是否可以让spring-data-rest验证PUT、DELETE、PATCH /{repository}/{id}/{property}的值是否匹配
发布于 2020-10-14 23:58:23
根据official documentation的说法,Spring Data REST需要一个带有@Version注释的版本字段来实现ETag。
如果要对嵌入属性(字段)进行版本化,如何分别对单个嵌入属性进行版本化?答案是不可能的。
如果您想要对引用的属性(JPA联接)进行版本控制,那么您应该向/{that- property -repository}/{id}而不是/{repository}/{id}发出一个PUT/PATCH/DELETE请求。
https://stackoverflow.com/questions/64355212
复制相似问题