And*_*ser 2 java rest spring spring-mvc spring-data
我最近实现了Spring Data REST(http://www.springsource.org/spring-data/rest),以便通过REST接口自动公开CRUD功能.
GET和POST都按预期工作,但是在使用PUT动词时我得到405方法不允许.
根据文件
Verb Method
GET CrudRepository<ID,T>.findOne(ID id)
POST CrudRepository<ID,T>.save(T entity)
PUT CrudRepository<ID,T>.save(T entity)
DELETE CrudRepository<ID,T>.delete(ID id)
Run Code Online (Sandbox Code Playgroud)
默认情况下,所有这些方法都将导出到客户端.我已经阅读了这里的文档(http://static.springsource.org/spring-data/rest/docs/1.1.0.M1/reference/htmlsingle/),但似乎无法找到这种行为的原因.
任何人都可以建议我可能出错的地方?我提供了一个RepositoryRestMvcConfiguration类,它定义了我所有Entity类的资源映射.
sou*_*eck 12
您正尝试使用相同的URL POST
和PUT
请求,但PUT
通常需要必须更新的对象的ID.
Spring确实有映射localhost:8080/<applicationname>/<entityName>
,但仅用于POST
请求,因此错误.
尝试使用PUT
:
http://localhost:8080/<applicationname>/<entityName>/<objectId>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5760 次 |
最近记录: |