I am trying to optimize some mobile web pages (or number of server requests more accurately) by in-lining some CSS in the HTML downloaded with initial request.
These pages are delivered from our Vosao-based CMS, and use Apache Velocity macros.
This works fine, as expected.
<link rel="stylesheet" type="text/css" media="screen" href="/file/downloads/contact.css"
This fails
<style>
#include( "/file/downloads/contact.css" )
</style>
as Velocity cannot find the file, with this output
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource '/file/downloads/contact.css'
and this in logs
org.apache.velocity.runtime.log.CommonsLogLogChute log: ResourceManager : unable to find resource '/file/Downloads/contact.css' in any resource loader.
E 2012-06-20 13:59:19.688
org.apache.velocity.runtime.log.CommonsLogLogChute log: #include(): cannot find resource '/file/Downloads/contact.css', called at vm[line 7, column 3]
I have read the velocity documentation (about resource ROOT property) and even spent some time on the source code. I've played with the properties for that at load time....and no luck.
How can I get Velocity to do an include of either a static file in my /war dir, or getter it to include from a path?
I have successfully used like this:
Maybe is your file path wrong?
I think #include performs the loading of another template file (.vm), not a css file.