Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Quickie</strong></p> <p>If you are using plain JSP views (as is most common), then simply add</p> <pre><code>&lt;% response.setStatus( 403 ); %&gt; </code></pre> <p>somewhere in your view file. At the top is a nice place.</p> <p><strong>Detail</strong></p> <p>In MVC, i would always set this in the view, and in most cases with Spring-MVC, use the <code>SimpleMappingExceptionResolver</code> to present the correct view in response to a thrown runtime Exception. </p> <p>For example: create and throw a <code>PermissionDeniedException</code> in your controller or service layer and have the exception resolver point to a view file <code>permissionDenied.jsp</code>. This view file sets the 403 status and shows the user an appropriate message.</p> <p>In your Spring bean XML file:</p> <pre><code>&lt;bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"&gt; &lt;property name="exceptionMappings"&gt; &lt;props&gt; &lt;prop key="PermissionDeniedException"&gt; rescues/permissionDenied &lt;/prop&gt; ... set other exception/view mappings as &lt;prop&gt;s here ... &lt;/props&gt; &lt;/property&gt; &lt;property name="defaultErrorView" value="rescues/general" /&gt; &lt;/bean&gt; &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt; &lt;property name="prefix" value="/WEB-INF/views/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; </code></pre> <p>If you need to implement a user login mechanism, take a look at <a href="http://static.springframework.org/spring-security/site/index.html" rel="noreferrer">Spring Security</a> (formerly Acegi Security).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload