Announcement Announcement Module
Collapse
No announcement yet.
Viewing images not within webapp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Viewing images not within webapp

    Hi,
    I am very new to Spring. I am starting a web MVC project to display video shots as thumbnails.
    These are all stored within a repository, not within the webapp domain, eg on the filesystem /repo/thumbnails/.....

    I would like a user to be able to stipulate where the repo path is, via a form, and then use that path to retrieve the images.

    I have tried using the <mvc:resources> tag in the config, but I still am unable to get to any external file.

    Do I need to setup the classpath to include this directory. If so how do I enable this to be programatically changed?

    There must be an easy way to do this, I just can't get it to work.

    Can someone please give me a simple example please.

  • #2
    OK I have worked it out:
    In server-context.xml I now have:
    <resources mapping="/resources/**" location="/resources/,file:/home/john/temp_jpgs/" />

    This will allow the images inside the file system directory /home/john/temp_jpgs/ to be accessed using the /resources/ map.

    So in my jsp:

    <%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
    .....
    <s:url value="${item['imagePath']}" var="thumb_uri" htmlEscape="true" />
    <img src="${thumb_uri}" />

    And in the controller I use the following code to create a List of hashes:

    List<Map<String, String>> listOfMaps = new ArrayList<Map<String, String>>();
    Map<String,String> imageMap = new HashMap<String,String>();

    imageMap.put("imagePath", "/resources/image[1].jpg");
    imageMap.put("imageTime", "00:00:01");

    listOfMaps.add(imageMap);

    imageMap = new HashMap<String,String>();


    imageMap.put("imagePath", "/resources/image[2].jpg");
    imageMap.put("imageTime", "00:00:02");
    listOfMaps.add(imageMap);

    model.addAttribute("thumbs", listOfMaps);

    Seems to work fine.

    Comment


    • #3
      Helli friends,

      Thanks for sharing this with us.

      Comment

      Working...
      X