Results 1 to 3 of 3

Thread: is it possible to load a resource with wildcard mappings?

  1. #1
    Join Date
    Mar 2010
    Location
    Chicago, IL
    Posts
    10

    Default 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. #2
    Join Date
    Oct 2008
    Location
    Poland, Wrocław
    Posts
    429

    Default

    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

  3. #3
    Join Date
    Mar 2010
    Location
    Chicago, IL
    Posts
    10

    Default

    thanks that worked great for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •