spring bean configuration
-
19-08-2019 - |
Question
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, e.g. /usr/bin
Cheers, Don
Solution
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?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow