title: How to reuse customized response in spring boot
body: <p>I wrote an simple api by spring boot.<br>
  And when save is success, it response with 200 httpStatus code that I made by json type.<br>
  But I want to use this response globally reusing it. <br></p>
  <pre><code>@PostMapping(&quot;/notice&quot;)
  public ResponseEntity&lt;Object&gt; createNotice(@RequestBody @Valid NoticeDto noticeDto, HttpServletResponse response) {
      noticeService.createNotice(noticeDto);
  
  
      ObjectNode jsonResponse = null;
      try {
          ObjectMapper mapper = new ObjectMapper();
  
          jsonResponse = mapper.createObjectNode();
          jsonResponse.put(&quot;code&quot;, 200);
          jsonResponse.put(&quot;success&quot;, true);
          jsonResponse.put(&quot;msg&quot;, &quot;OK&quot;);
      } catch (Exception ex) {
          ex.printStackTrace();
      }
  
      PrintWriter out = response.getWriter();
      response.setStatus(200);
      response.setContentType(&quot;application/json&quot;);
      response.setCharacterEncoding(&quot;UTF-8&quot;);
      out.flush();
  
  }
  </code></pre>
  <p>For example, I want to use it like this.</p>
  <pre><code>@PostMapping(&quot;/notice&quot;)
  public ResponseEntity&lt;Object&gt; createNotice(@RequestBody @Valid NoticeDto noticeDto, HttpServletResponse response) {
      noticeService.createNotice(noticeDto);
      
      return successResponse something...
  }
  </code></pre>
  <p>For this purpose, which class file should I write?<br>
  Thank you for reading my questiong.</p>