Spring resource in WEB-INF

I have a bean that has a type property File. I want this property to point to a file under WEB-INF.

It seems to me that I ServletContextResourceLoadershould have this work, one way or another, but I'm not trying to do anything to complete this work.

I am trying to avoid using this in Java code.

+3
source share
1 answer

If this property should remain in the form of the "File" type, you will have to jump through some hoops.

, , bean, Resource, String, Spring ServletContextResource , File Resource.getFile().

public class MyBean {

   private File file;

   public void setResource(Resource resource) {
      this.file = resource.getFile();
   }
}

<bean class="MyBean">
   <property name="resource" value="/WEB-INF/myfile">
</bean>
+4

Source: https://habr.com/ru/post/1754141/


All Articles