Announcement Announcement Module
Collapse
No announcement yet.
is it possible to load a resource with wildcard mappings? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • is it possible to load a resource with wildcard mappings?

    Hi

    After looking here: http://static.springsource.org/sprin...resources.html

    I see this is possible in section 4.7.2 for loading applicationContext but is there anything I can do for regular resources?

    I have one json file on the classpath that changes frequently and rather than hardcode the path I am looking for something more flexible.

    Ideally I would like something like this:
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContex t(servletContext);

    Resource r = ctx.getResource("WEB-INF/classes/*.json");

    Any ideas?

    Thanks.

  • #2
    Hi

    A quick copy-paste from my working code:
    Code:
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    List<Resource> resourcesForDokType = Arrays.asList(resolver.getResources("classpath*:*.xml"));
    Then see what you'll get in "resourcesForDokType".

    regards
    Grzegorz Grzybek

    Comment


    • #3
      thanks that worked great for me.

      Comment

      Working...
      X