创建grails自定义ResourceMapper

时间:2013-12-12 23:28:00

标签: grails

我使用资源插件中的说明创建了以下资源映射器:

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}"
    }
}

该文件位于grails-app / resourceMappers

我的班级甚至从未被召唤过。我有一个从未命中的调试断点集。是否还需要设置其他配置?

2 个答案:

答案 0 :(得分:0)

我很确定你需要改变

def phase = MapperPhase.MUTATION

 static phase = MapperPhase.MUTATION

答案 1 :(得分:0)

删除此行

static defaultIncludes = ['/ js / **']

并检查您的断点是否被击中。看起来它只是找不到js目录。

如果有效,请将上述行更改为

static defaultIncludes = ['js / **']