The website has moved

Note: the website moved to You're being redirected.

Tuesday, July 30, 2013

How To create a customized "Access Denied" landing page
with Spring 3 and Tiles 3
Your new site finally needs the last thouch.
You're wasting your time walking back and forth in your room trying to think about what to do to improve it: suddenly, you remember that time when you first saw a customized landing page for that (otherwise) annoying 403 error.
Now the question is: how the hell can I do that?

And here's the answer!

(Yes, that was an absolutely boring post introduction, but I'm not a writer. Not yet, at least.)

The steps!

1) In security-config.xml

<security:access-denied-handler error-page="/accessdenied">

2) In webmvc-config.xml

<mvc:view-controller path="/accessdenied" view-name="common.accessdenied">

3) In tiles-defs.xml (your tiles definitions file) define the tile for your landing page

    <definition extends="template" name="errors.denied">
        <put-attribute name="content" value="/WEB-INF/views/denied.jsp">

Obviously, change the paths consequently to your denied.jsp location.
You're done!

Now, you just have to customize the jsp in order to show the contents you want.
I suggest you to take a look at the 404 github pages: they're awesome.