I created the following resource mapper using the instructions from the resources plugin:
import org.grails.plugin.resource.mapper.MapperPhase
import org.apache.commons.logging.LogFactory
class VersionResourceMapper {
def phase = MapperPhase.MUTATION
def log = LogFactory.getLog(this.class)
static defaultIncludes = [ '/js/**' ]
def map(resource, config) {
def query = [v:'1.01']
resource.actualUrl = resource.actualUrl + '?' + query.collect { it }.join('&')
//resource.updateActualUrlFromProcessedFile()
if (log.debugEnabled) log.debug "Modified URL: ${resource.actualUrl}"
log.info "Modified URL: ${resource.actualUrl}"
}
}
The file is located in grails-app/resourceMappers
My class never even gets called. I have a debug breakpoint set which is never hit. Is there some other configuration that has to be set?
I'm pretty sure that you need to change
def phase = MapperPhase.MUTATION
to
static phase = MapperPhase.MUTATION
remove this line
static defaultIncludes = [ '/js/**' ]
and check if your breakpoint is hit. It looks like it is just not finding the js directory.
If that works change the above line to
static defaultIncludes = [ 'js/**' ]
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.