使用Spring MVC 3.1+ WebApplicationInitializer以编程方式配置session-config和error-page [英] Using Spring MVC 3.1+ WebApplicationInitializer to programmatically configure session-config and error-page

查看:248
本文介绍了使用Spring MVC 3.1+ WebApplicationInitializer以编程方式配置session-config和error-page的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WebApplicationInitializer 提供了一种以编程方式表示标准web.xml文件的一部分的方法 - servlet,过滤器,监听器。

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

但是我无法找到使用WebApplicationInitializer表示这些元素(session-timeout,error-page)的好方法,是否仍然需要维护一个这些元素的web.xml?

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>


推荐答案

我对这个主题进行了一些研究并找到了对于某些配置,例如sessionTimeOut和错误页面,你仍然需要拥有web.xml。

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.

看看这个链接

希望这对您有所帮助。
干杯。

Hope this helps you. Cheers.

这篇关于使用Spring MVC 3.1+ WebApplicationInitializer以编程方式配置session-config和error-page的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆