How to disallow PUT while allowing POST and PATCH in Spring Data REST?

北城余情 提交于 2019-12-06 05:59:03

问题


Is it possible to completely disallow PUT for a repository in Spring Data REST while POST on the collection and PATCH on the item remain possible?

The rationale behind this is that a PUT typically allows for replace semantics, but in our case the resource can only be created via POST on the collection, partially updated via PATCH on the item (using specific UI dialogs... each of which only supports a particular partial update), or deleted via DELETE on the item.


回答1:


If you have Spring security in your application, then this can be done by adding intercept-url to deny access to PUT method on Spring data repository, something like below:

<security:intercept-url pattern="/{repositoryPath}" method="PUT" access="denyAll" />


来源:https://stackoverflow.com/questions/24766067/how-to-disallow-put-while-allowing-post-and-patch-in-spring-data-rest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!