Using Spring MVC 3.1+ WebApplicationInitializer to programmatically configure session-config and error-page

Biju Kunjummen picture Biju Kunjummen · May 30, 2012 · Viewed 12.1k times · Source

WebApplicationInitializer provides a way to programmatically represent a good portion of a standard web.xml file - the servlets, filters, listeners.

However I have not been able to figure out a good way to represent these elements(session-timeout, error-page) using WebApplicationInitializer, is it necessary to still maintain a web.xml for these elements?

<session-config>
    <session-timeout>30</session-timeout>
</session-config>

<error-page>
    <exception-type>java.lang.Exception</exception-type>
    <location>/uncaughtException</location>
</error-page>

<error-page>
    <error-code>404</error-code>
    <location>/resourceNotFound</location>
</error-page>

Answer

Japan Trivedi picture Japan Trivedi · May 30, 2012

I done a bit of research on this topic and found that for some of the configurations like sessionTimeOut and error pages you still need to have the web.xml.

Have look at this Link

Hope this helps you. Cheers.