Пример #1
0
 public void setData(Object data) {
   if (data == null) {
     response.setStatus(HttpStatus.NO_CONTENT);
   } else if (data instanceof String) {
     String content = (String) data;
     response.setContentType("text/plain");
     response.setCharacterEncoding("utf-8");
     response.setContentLength(content.getBytes().length);
   } else {
     try {
       service.serialize(data, this.request, this.response);
     } catch (HttpException e) {
       setStatus(e.getStatus(), e.getMessage());
     } catch (IOException e) {
       setStatus(HttpStatus.INTERNAL_SERVER_ERROR, "Serialization failed");
     }
   }
 }
Пример #2
0
 public void setStatus(HttpStatus status, String message) {
   response.setStatus(status, message);
 }
Пример #3
0
 public void setStatus(HttpStatus status) {
   response.setStatus(status);
 }