【发布时间】:2017-07-31 17:38:19
【问题描述】:
我有一个使用 jax-rs 的 java ee 应用程序。但是当我在返回 json 的调用中返回布尔值时,它会给出 500 错误。
@GET
@Path("/test")
@Produces("application/json")
public boolean test() {
return true;
}
上面的代码会给出这个通用的错误信息:The server encountered an internal error that prevented it from fulfilling this request.
如果我删除 @Produces("application/json") 它确实有效但返回“文本/纯文本”。
【问题讨论】:
-
boolean 实际上不是 json。你可以试试像 {"value":true} 这样的地图吗?
-
@OP:你需要这个答案:stackoverflow.com/a/13595212/767881
标签: java json jakarta-ee jax-rs payara