Grails:如何更改网站图标?

时间:2013-11-25 09:25:12

标签: grails favicon

我尝试替换favicon.ico文件夹中的/web-app/images/,但它不起作用:我的网站仍然使用通常的Grails图标。我还需要做些什么?

4 个答案:

答案 0 :(得分:12)

尝试更改views\layout\main.gsp

<html>  
    <head>  
        <title><g:layoutTitle default="Grails" /></title>  
        <link rel="stylesheet" href="${createLinkTo(dir:'css',file:'main.css')}" />  
        <link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" />  
        <g:layoutHead />  
        <g:javascript library="application" />                  
    </head>  
    <body>  
        <div id="spinner" class="spinner" style="display:none;">  
            <img src="${createLinkTo(dir:'images',file:'spinner.gif')}" alt="Spinner" />  
        </div>      
        <div class="logo"><img src="${createLinkTo(dir:'images',file:'grails_logo.jpg')}" alt="Grails" /></div>     
        <g:layoutBody />        
    </body>     
</html>

和评论

<link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" /> 

或清理浏览器的缓存。 ; - )

答案 1 :(得分:4)

使用grails assets插件,您必须使用:

<head>
    ...
    <asset:link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
</head>

答案 2 :(得分:0)

favicon.ico文件放入PROJECT/grails-app/assets/文件夹,

添加到UrlMappints

class UrlMappings {

    static mappings = {
      ......
      "/favicon.ico"  (uri: "/assets/favicon.ico")
    }
}

答案 3 :(得分:0)

将图标文件放置在以下路径中:

grails-app\assets\images\favicon.ico

然后将其添加到html的head元素中:

<link rel="shortcut icon" href="/assets/favicon.ico">