如何在Chrome中设置woff字体的mime类型,就像字体真棒引导程序库一样?
答案 0 :(得分:1)
通过将以下FontResourceMapper.groovy
文件放入文件夹中来创建Grails custom mapper:grails-app/resourceMappers/
<强> FontResourceMapper.groovy 强>
import org.grails.plugin.resource.mapper.MapperPhase
class FontResourceMapper {
static phase = MapperPhase.ALTERNATEREPRESENTATION
static defaultIncludes = ["**/*.woff"]
def map(resource, config) {
// Changes "application/octet-stream" to correct MIME type to avoid browser warning
resource.requestProcessors << { req, resp ->
resp.setHeader("Content-Type", "application/font-woff")
}
}
}
答案 1 :(得分:0)
在Config.groovy中:
grails.mime.types = [
all: '*/*',
atom: 'application/atom+xml',
css: 'text/css',
...
woff: 'font/opentype'
]