1. Add resource member in your class
public class A {
...
private org.springframework.core.io.Resource myResource;
public void setMyResource(org.springframework.core.io.Resource myResource) {
this.myResource = myResource;
}
...
// You Code
// Now you can get the file/stream from the resource:
// myResource.getFile();
// myResource.getInputStream();
...
}
2. Define the resource in spring configuration
<bean id="myBean" class="A">
<property name="myResource">
<value type="org.springframework.core.io.Resource">{path}</value>
</property>
</bean>
The {path} could be:
- /WEB-INF/...
- classpath:/...
- file:/c:/...
No comments:
Post a Comment