我正在尝试使用mithril.js的spring-data-rest。但是,我一直从存储库而不是json获得xml响应。
我有一个存储库:
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends JpaRepository<Person, Long> {并使用以下命令请求:
var users = m.request({method: "GET", url: "/api/people/"});但是,我只是在xml响应中获得了一个字符串列表。
我试着检查以下来源,尽管我可能看错了并指出了错误的来源:
发现mithril将accept标头设置为
xhr.setRequestHeader("Accept", "application/json, text/*")但是,听起来spring-data-rest处理请求的方式是
@ResponseBody
@SuppressWarnings({ "unchecked" })
@RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET, produces = {
"application/x-spring-data-compact+json", "text/uri-list" })
public Resources<?> getCollectionResourceCompact(RootResourceInformation repoRequest, DefaultedPageable pageable,spring-data-rest source: line 171-173
而不是
@ResponseBody
@RequestMapping(value = BASE_MAPPING, method = RequestMethod.GET)
public Resources<?> getCollectionResource(final RootResourceInformation resourceInformation,on spring-data-rest source:第210-213行
我的ajax请求有什么问题吗?
发布于 2015-06-17 10:21:19
使用curl创建请求并使其按您所认为的方式工作。在这之后,处理mithril部分。
https://stackoverflow.com/questions/30872066
复制相似问题