Mar*_*vic 3 java spring servlets spring-mvc
我遇到了一个非常简单的任务:如何在Spring MVC 3.2配置中设置ServletContext属性?
我发现类似的东西可以用ServletContextPropertyPlaceholderConfigurer来完成,但是从春季3.1这被视为过时:
" 已过时.在Spring 3.1赞成PropertySourcesPlaceholderConfigurer的与StandardServletEnvironment结合. "
这并没有告诉我多少,因为我不知道如何使用StandardServletEnvironment.
有什么建议吗?
您可以使用ServletContextAttributeExporter.ServletContextAttributeExporter
在配置文件中定义如下的bean,并将其attributes
属性设置为key and value
要放入的对的映射ServletContext
:
<bean class="org.springframework.web.context.support.ServletContextAttributeExporter">
<property name="attributes">
<map>
<entry key="myKey" value="1" />
</map>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3851 次 |
最近记录: |