title: Spring redirect to another page on button click
body: <p>I'm new to the Spring framework. At the moment I've got two <code>HTML</code> pages and when a button is clicked on the first one I want to redirect to the second page.</p>
  
  <p>At the moment I'm doing this in a really hacky way.</p>
  
  <p>The first page is just a log in page and depending on the user logged I'm redirection to a specific page. On the login page I've got two hidden <code>&lt;a&gt;</code> like these</p>
  
  <pre><code>&lt;a href="admin" class="button" id="btnAdmin" style="opacity: 0;"&gt; Login as tutor &lt;/a&gt;
  &lt;a href="student" class="button" id="btnStudent" style="opacity: 0;"&gt; Login as student&lt;/a&gt;
  </code></pre>
  
  <p>Then using JavaScript I'm triggering this <code>&lt;a&gt;</code> to be clicked when the Login button is clicked. That way I'm successfully redirecting to the <code>admin.html</code> or <code>student.html</code> pages. The problem is that once I'm redirected to these pages the page is not rendered correctly (the js is not loaded correctly) so I need to refresh the page to see the proper content of the page. I assume that the reason for is because I'm redirecting in such a hacky way. So my question is - having a button like this (ignore the <code>JQuery Mobile</code>)</p>
  
  <pre><code>&lt;input type="button" id="btnLogin" class="btnLogin" value="Sigh in" data-theme="b"/&gt;
  </code></pre>
  
  <p>how to redirect properly in the Spring framework?</p>
  
  <p>PS I'm coming from ASP.NET background so I was thinking of some sort of button click event handler in the back end, and then doing something like <code>Response.Redirect("newpage");</code></p>