title: How to implement view-based spring security for links?
body: <p>I have a new project and I want to implement <code>spring-security</code> along with other components of <code>spring framekwork</code>.</p>
  
  <p>I plan to implement spring security into 2 levels, <strong>Request URL-level</strong> and <strong>view-level</strong></p>
  
  <ul>
  <li><p>For <strong>Request URL-Level</strong>, I'd use the <code>&lt;intercept-url&gt;</code> tag to restrict URL access only for authorized users.</p></li>
  <li><p>For <strong>View-Level</strong> security, I'll use it into two parts of the application; </p>
  
  <ul>
  <li>For the web app <strong>menu</strong> to restrict menus for users who authorized to.</li>
  <li>And <strong>inside the pages</strong> to restrict some parts of the page for users who authorized to.</li>
  </ul></li>
  </ul>
  
  <hr>
  
  <p>The confusion I had is regarding implement spring security for <strong>menu</strong> links.<br>
  Hence I need to use spring <code>taglibs</code> <code>&lt;authorize&gt;</code> tag's <code>url</code> attribute (to reuse<code>&lt;intercept-url&gt;</code> patterns/access combination) , then I'll need to write menu links by hand like this:</p>
  
  <pre><code>&lt;security:authorize url="/admin/superadmin/**" &gt;
          &lt;a href="superadmin/index.jsp"&gt;Super admin page&lt;/a&gt;
  &lt;/security:authorize&gt;
  </code></pre>
  
  <p>Where I've the following intercept url rule:</p>
  
  <pre><code>&lt;intercept-url pattern="/admin/superadmin/**" access="hasRole('ROLE_SUPER_ADMIN')" /&gt;
  </code></pre>
  
  <p>The point is, I have all the rules in the Database table, and I want to draw links dynamically based on the roles/links saved in the table. </p>
  
  <p>So, <strong><em>the question is</em></strong> how to draw menu links dynamically, and at the same time still use the <code>&lt;authorize&gt;</code> taglib?</p>