【发布时间】:2018-07-10 12:15:31
【问题描述】:
只有当 mime-type 为 application/json 时,我如何才能指定 @RepositoryRestResource 指向响应?
@RequestMapping 示例
带有Accept : application/json 的GET-Request 返回json
@RequestMapping(path="/path", headers ="Accept=application/json")
public String withHeader() {
return "{this:json}";
}
不带Accept : application/json 标头的GET-Request 返回html
@RequestMapping("/path" )
public String withoutHeader() {
return "<html>...</html>";
}
【问题讨论】:
标签: java json spring rest spring-boot