Search code examples
javaweb-applicationsweb.xmlservlet-filtersshiro

Apache shiro web application index page as default page


I am new to Apache Shiro web application development. I have a index.html in my web directory which inturn as a link to login.htm I want the index.html to be my default page, i.e, when url is like :
localhost:8080/myapp/ or localhost:8080/myapp/index.html
It should show index.html

How can I prevent shiro filter with url pattern /*. I mean shiro must not filter or process the index.html.
Now it keeps on redirecting to login.htm because of obivious reason as it is configured usually in web.xml and shiro.ini


Solution

  • Set index.html as welcome-file in web.xml

    web.xml

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    

    In shiro.ini allow anonymous users for your index.html URL. Give an entry for index.html before your /* entry

    [urls]
    
    /index.html = anon
    /*={your mapping}