title: Return HTML or JSON in a Spring Controller Method
body: <p>I am wondering the correct way to return HTML or JSON inside the same method depending on logic on a Spring Controller method.  I have done this in .NET, just need to know how to do this in Spring.</p>
  
  <pre><code>    UserModel user = new UserModel();       
      user.setFirstName("Michael");
      user.setLastName("Flynn");
  
      model.getList().add(user);
      model.setSearchTerm("test");
  
      if(true)
      {
          return new ModelAndView("controls/tables/users", "model", model);
      }
      else
          return model;
  </code></pre>