开发者

Spring application context : webapp folder variable?

开发者 https://www.devze.com 2022-12-20 00:46 出处:网络
Greetings, Is there any Spring variable for Web application folder? I want to assign a bean property as following.

Greetings,

Is there any Spring variable for Web application folder? I want to assign a bean property as following.

Where ${WEBAPP-FOLDER} is the absolute path of the web-app folder.

Any tips?

<bean id="compass" class="org.compass.spring.LocalCompassBea开发者_运维知识库n">
            .
                .
                <prop key="compass.engine.connection">file:///${WEBAPP-FOLDER}/WEB-INF/searchIndex</prop>       
</bean>


No, but you can obtain it through a ServletContextListener, by calling

event.getServletContext.getRealPath("/")

You can now set it in a static variable (which will logically be a constant), or get the spring application context and set it manually (via WebApplicationUtils) in the bean.

0

精彩评论

暂无评论...
验证码 换一张
取 消