title: Spring MVC. Redirect page
body: <p>I have a controller wich handles URL studentEdit.html. When I pass to controller value 'get' using AJAX I need to redirect to another page viewStudents.html, but nothing happens. I stay on the same page. The method returns the ModelAndView, but why it does not redirect to another page I do not know. </p>
  
  <p>I also tried to set url as:</p>
  
  <p>redirect:viewStudents.html and redirect:viewStudents</p>
  
  <p>but it did not helped.</p>
  
  <pre><code>@RequestMapping(value = "/studentEdit.html", method = RequestMethod.GET)
  public ModelAndView getStudentProfile(@RequestParam(value = "get", required = false) String get) {
  
      if(get != null &amp;&amp; get.equals("get")) {
          return new ModelAndView("redirect:/viewStudents.html");
      } else {
          ModelAndView mav = new ModelAndView("studentEdit"); 
          return mav;
      }
  }
  
  
  function getStudent() {
              $.ajax({
                  type: "GET",
                  url: "/IRSystem/studentProfileEdit.html",
                  data: "get=" + 'get',
                  success: function(response) {
  
                  },
                  error: function(e) {
                      alert('Error' + e);
                  }
  
              });
          }
  </code></pre>
  
  <p>I would appreciate any information, thank you.</p>