I have a web application where each of the JSP should be linked to a help pdf file. The files are located outside the web container / application context, but are located within the same server.
I am trying to access them using the spring mvc resource tag but I am still unable to access the pdf file.
Any help is appreciated.
Here is the configuration In a windows env, files are located in C:\\workspace\\shared\\data\\help[all pdfs are here]
I created a jvm argument to access the files -
JVM Argument
-Dhelp.dir=/workspace/shared/data/help
spring mvc resource tag -
<mvc:resources mapping="/help/*" location="file:/#{systemProperties.help.dir}/"/>
I get a 404 error while trying to access the pdf(s)
Glassfish / JDK 1.6
When I click on the Link, the URL generated is -
http://localhost:8080/workspace/shared/data/help/abc.pdf
My actual web application context is something like this -
http://localhost:8080/MyApp
You just need a small fix with SpEL syntax,
<mvc:resources mapping="/help/*" location="file:#{systemProperties['help.dir']}"/>
and for JVM argument :
-Dhelp.dir=/workspace/shared/data/help/
with leading and trailing slashes to get it all work
see : http://wordgraphs.com/post/1751/Serving-a-resource-from-outside-the-context-root-in-Spring-MVC and Spring Expression Language (SpEL)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.