I want to use CDN to serve static content like CSS, JavaScript and images in a project created with Spring MVC. But I didn't how to do it.
I'm new to Spring and I have seen some posts on the web:
- JSP/Spring MVC and CDN?
- How to use property from property file specified in PropertyPlaceholderConfigurer in JSP
- How to show values from property file in JSP in a spring MVC app
- http://tshikatshikaaa.blogspot.com/2012/11/serving-static-resources-with-spring-mvc.html
But they didn't explain how to implement it.
For example:
In the past, I use <c:url>
tags:
<img src="<c:url value="/path/to/image" />" alt="desc" />
When I use CDN, I may use following code:
<img src="${env.cdnUrl}/mypath/pic.jpg" />
But where should I put ${env.cdnUrl}
(in web.xml
or dispatcher-servlet.xml
(the configuration of Spring MVC))? And how to get the parameter in JSP?
Please help me. Thanks.