【发布时间】:2015-05-03 22:22:57
【问题描述】:
我想提供一个booleanREST 服务,它只提供真/假布尔响应。
但以下不起作用。为什么?
@RestController
@RequestMapping("/")
public class RestService {
@RequestMapping(value = "/",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_XML_VALUE)
@ResponseBody
public Boolean isValid() {
return true;
}
}
结果:HTTP 406: The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
【问题讨论】:
-
试着用一个布尔属性(状态或者你喜欢的)创建一个@XMLRootElement。
-
好的,我明白了。但是如果我返回纯文本真/假就足够了。我绑定了
MediaType.TEXT_HTML_VALUE,但遇到了同样的 406 错误。 -
"根据请求“accept”标头不可接受"您是如何尝试的?
-
刚刚在webbrowser(firefox)中打开了rest url。
标签: java spring rest spring-boot