Spring 4获取init参数

时间:2015-05-23 02:09:35

标签: java spring spring-mvc servlets

我在web.xml中声明了一些必须为我的spring应用程序定义的init参数。在我的控制器里面,我有:

@Override
public void setServletContext(ServletContext servletContext){
    this.servletContext = servletContext;
    validateServletInitParameters();
} 

validateServletInitParameters()内部我想检查以确保所有值都存在,如果不存在,则抛出相当于servlet异常的值。我怎么能在Spring(4)中做到这一点? setServletContextMethod不会抛出任何异常,所以我不知道该怎么做。

init参数在web.xml中声明:

<context-param>
    <description>Represents the maximum input amount</description>
    <param-name>maximumInputAmount</param-name>
    <param-value>500.00</param-value>
</context-param>

0 个答案:

没有答案