title: How can I get data from spring controller by ajax?
body: <p>I have an <code>ajax</code> on a <code>jsp</code> page which calls a spring controller through URL <code>/check</code> .  </p>
  
  <pre><code>$.ajax({
      type : "GET",
      url : "${pageContext.request.contextPath}/check",
      data : {
      "id" : ${articleCount}
      },
      success: function(data){
      //response from controller
      }
  });
  </code></pre>
  
  <p>Now, the controller looks like,</p>
  
  <pre><code>@RequestMapping("/check")
  public String check(@RequestParam Integer id, HttpServletRequest request,
          HttpServletResponse response, Model model) {
      boolean a = getSomeResult();
      if (a == true) {
          model.addAttribute("alreadySaved", true);
          return view;
      } else
          model.addAttribute("alreadySaved", false);
  
      return view;
  }
  </code></pre>
  
  <p>I sent data using model and tried to access it in <code>success: function(data)</code> as <code>"${alreadySaved}"</code>but it shows blank. </p>
  
  <p>Is there any way I can receive that <code>true/false</code> data on the view page?</p>