resource
目的 Purpose
Generates a link (URI) string. Can be used in an href, JavaScript, Ajax call, etc.This tag is aware of the Resources plugin, and if it's installed the tag will correctly generate links to static resources processed by the plugin.使用例 Examples
Example usages for the "shop" app:// generates "/shop/css/main.css" <g:resource dir="css" file="main.css" />// generates "http://portal.mygreatsite.com/css/main.css" <g:resource dir="css" file="main.css" absolute="true" />// generates "http://admin.mygreatsite.com/css/main.css" <g:resource dir="css" file="main.css" base="http://admin.mygreatsite.com"/>
<link type="text/css" href="${resource(dir: 'css', file: 'main.css')}" />
<link type="text/css" href="/shop/css/main.css" />
詳細 Description
属性 Attributes
base
(optional) - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of theabsolute
property if both are specified.contextPath
(optional) - the context path to use (relative to the application context path). Defaults to "" or path to the plugin for a plugin view or template.dir
(optional) - the name of the directory containing the resourcefile
(optional) - the name of the resource fileabsolute
(optional) - Iftrue
will prefix the link target address with the value of thegrails.serverURL
property fromConfig.groovy
, or http://localhost:<port> if there is no setting inConfig.groovy
and not running in production.plugin
(optional) - The plugin to look for the resource in