我正在尝试编写一个自定义ExceptionMapper
并且我想返回text/plain
,但是Response
返回的或者链中的某些东西坚持用<pre></pre>
标签包装我的内容。
这是我尝试过的,我尝试过没有设置MediaType
:
final Response.ResponseBuilder rb = Response.status(500);
rb.entity(e.getCause().getMessage());
return rb.build();
我也尝试过设置MediaType.TEXT_PLAIN_TYPE
:
final Response.ResponseBuilder rb = Response.status(500);
rb.type(MediaType.TEXT_PLAIN_TYPE);
rb.entity(e.getCause().getMessage());
return rb.build();
在这两种情况下,我都会收到用 HTML 包装的异常消息:
<html>
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
com.google.appengine.api.oauth.InvalidOAuthParametersException:
</pre>
</body>
<style type="text/css"></style>
</html>
我认为这可能是包装内容的浏览器,我在 Chrome 和 Safari 中得到了完全围绕纯文本输出包装的相同 HTML 块,但是当我使用curl
.
[jhr@Blackintosh] [~]
curl http://funny-pages.appspot.com/image/all
com.google.appengine.api.oauth.InvalidOAuthParametersException:
我该怎么做才能让它在浏览器中显示未修饰的内容?