[插件] 静态资源插件

Static Resources Plugin

When you are serving images and other binary files you usually want to do this via a high performance native httpd such as Apache. This means you need (ideally) to store them in a location outside of the webapplication, but you also need to be able to access them locally while you are developing your grails application.

This plugin makes it easy. Using it means:

  • You no longer have to upload all your, perhaps very large, static content when you update your web application - i.e. smaller WAR sizes
  • Your static resources can be served faster by a highly optimized native httpd such as Apache
  • Your static resources still appear as part of your local Grails project filestructure
  • Your static resources can be updated on the live server without redeploying your WAR or editing the expanded WAR directory
  • Behaviour of your application is identical on server or locally, with no special effort from you (apart from setting up your live server's httpd to serve /resources/ alias)

Install the plugin into your project. Then simply make any links to resources that are to be served "externally" use the <g:resourceLinkTo dir="xxx" file="yyyy"/> tag.

Put your static resources into <yourproject>/static/

Run the application and your resources will be served by another mini httpd on port 8088, separate from the Grails Jetty. It serves everything under ./static.

To deploy to a live server, upload all your content from ./static (Which is not bundled in your WAR) to your httpd's filesystem.

When running on a live server, the plugin automatically prepends /resources/ to all resource links. You may therefore need to add a SetEnvIf line to exclude /resources/ from your mod_jk mappings, if you have your web-application mounted to /

If you don't have your webapplication mounted to /

you can either copy your ./static content to your httpd's document tree under /resources/ or to somewhere else and have an alias for /resources point to it.

You may also add a configuration option to change the location of the production files. The configuration key is: staticresources.production.resource.prefix

Marc Palmer marc AT anyware.co.uk

Get the ZIP file or source from: http://svn.grails-plugins.codehaus.org/browse/grails-plugins/grails-staticresources

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值