Best way to specify file paths in contexts
Hi there,
I have a particular requirement that I can't seem to find a "spring" way to solve. The requirement is simple, and at the root of it, it involves writing a file to a web application directory which then needs to be read and included as an image like a regular image src in a JSP. At issue is how to configure this file path using spring without relying on Spring specific APIs and without providing a hardcoded path.
I have a service that procudes an image. This image needs to be written into a path. I would like to configure this service with a property which contains the path. So for example:
Code:
class ImageServiceImpl implements ImageProvider {
private String saveFilePath
public void setSaveFilePath(String pathToSet) {
this.saveFilePath = pathToSet;
}
}
And in my applicationContext.xml I want to specify:
Code:
....
<bean name="serviceProvider" class="ImageServiceImpl">
<property name="saveFilePath"><value>/webroot/somedir</value></property>
</bean>
....
Is there a simple way to do this that will assume the path is relative to the web root?
Many thanks,
jc