Search code examples
jspspring-mvcspring-securityapache-tiles

Spring security does not redirect to home page


Hi I am facing a problem with redirecting my requests to the home page when I type the url of the base servlet.

When I type

http://localhost:8080/servlet/home

This works fine but when I type

http://localhost:8080/servlet/

I would like to see the home page whereas the system redirect it to the access denied page.

Controllers

@RequestMapping(value = "/home", method = RequestMethod.GET)
public String home() {
    return "home";
}

@RequestMapping(value = "/", method = RequestMethod.GET)
public String redirectHome() {
    return "home";
}

Spring security

<access-denied-handler error-page="/denied" />
<intercept-url pattern="/home" access="permitAll" />  
<intercept-url pattern="/" access="permitAll" />   
...

Solution

  • Check your web.xml file for welcome file.

         <welcome-file-list>
            <welcome-file>[your page]</welcome-file>
        </welcome-file-list>