in a web app, I need to serve static contents (images) located outside the application context directory. The overall application architecture requires me to use Tomcat to perform this. I thought I could benefit from Spring's <mvc:resources>
to configure a mapping between application URLs and directory contents. But AFAIK it's mapping
attribute only handles context relative, or classpath mappings. Hence, what I'd like to use :
<mvc:resources location="/images/**" mapping="/absolute/path/to/image/dir"/>
doesn't work. As I'd rather avoid writing a simple file transfer servlet, I'd be glad if anyone could give me some pointers on existing Spring based solutions/workarounds.
Many thanks.
Homer
<mvc:resources>
can serve resources from the outside, you need to use the usual Spring resource path syntax:There is one more simple correction
the code should be
<mvc:resources mapping="/images/**" location="file:/absolute/path/to/image/dir/"/>
Did you notice the difference ? You need to put '/' at the end of the absolute path.
or you can use the java configuration
Its working for me.