简体   繁体   中英

spring bean configuration

I want to specify a file system path as part of a Spring bean configuration. I know that I can set a path such as:

<bean id="myBean" class="com.example.BeanImpl">
  <property name="path" value="/WEB-INF/jsp"/>
</bean> 

An the path /WEB-INF/jsp is interpreted as being relative to the web application root. But how do I specify a path relative to file system root, eg /usr/bin

Cheers, Don

Use the file: predicate, like so:

<property name="path" value="file:c:/somefolder/someotherfolder"/>

Now that I think about it, its also about what the bean expects that path to be. Is it using the path to throw at a browser (which makes the whole file: thing relative on the client machine) or do you use it to programatically load a file which is on the server?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM