本文整理汇总了Java中org.kohsuke.stapler.StaplerResponse.getWriter方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerResponse.getWriter方法的具体用法?Java StaplerResponse.getWriter怎么用?Java StaplerResponse.getWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kohsuke.stapler.StaplerResponse
的用法示例。
在下文中一共展示了StaplerResponse.getWriter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exitWebHook
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
* Exit the WebHook
*
* @param result GogsResults
*/
private void exitWebHook(GogsResults result, StaplerResponse resp) throws IOException {
if (result.getStatus() != 200) {
LOGGER.warning(result.getMessage());
}
JSONObject json = new JSONObject();
json.element("result", result.getStatus() == 200 ? "OK" : "ERROR");
json.element("message", result.getMessage());
resp.setStatus(result.getStatus());
resp.addHeader("Content-Type", "application/json");
PrintWriter printer = resp.getWriter();
printer.print(json.toString());
}
示例2: createWriter
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
protected Writer createWriter(StaplerRequest req, StaplerResponse rsp, long size) throws IOException {
// when sending big text, try compression. don't bother if it's small
if(size >4096)
return rsp.getCompressedWriter(req);
else
return rsp.getWriter();
}
示例3: writeBody
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
private void writeBody(StaplerResponse response, JSONObject body) throws IOException {
response.setContentType("application/json");
PrintWriter writer = response.getWriter();
writer.write(body.toString());
writer.flush();
writer.close();
}
示例4: generateResponse
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void generateResponse(StaplerRequest req, StaplerResponse resp, Object node) throws IOException,
ServletException {
resp.setStatus(HttpServletResponse.SC_OK);
resp.setHeader(MetricsRootAction.CACHE_CONTROL, MetricsRootAction.NO_CACHE);
resp.setContentType(PLAIN_TEXT_CONTENT_TYPE);
final PrintWriter writer = resp.getWriter();
try {
writer.println(CONTENT);
} finally {
writer.close();
}
}
示例5: writeStatus
import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void writeStatus(StaplerResponse rsp, JSReturnCollection status) throws IOException {
Writer compressedWriter = rsp.getWriter();
JSONSerializer.toJSON(status).write(compressedWriter);
rsp.setStatus(200);
compressedWriter.flush();
}