Cannot be used FileSystemResource, you must use ServletContextResource:
new ServletContextResource(servletContext, "/myfile.xml");
Assuming, of course, that servletContext is available to you.
If you really want to use FileSystemResource, then you need to ask the container the directory is in and use it as a relative path, for example.
String filePath = servletContext.getRealPath("/myfile.xml");
new FileSystemResource(filePath);
Spring . , bean, Resource. , Spring , .
public class MyBean {
private Resource myResource;
public void setMyResource(Resource myResource) {
this.myResource = myResource;
}
}
beans:
<bean id="myBean" class="MyBean">
<property name="myResource" value="/path/under/webapp/root/of/my/file.xml">
</bean>
Spring ServletContextResource bean.