grails图像的绝对路径 [英] grails images absolute path
问题描述
我在标题模板< img src =images / slide-1.jpgalt =Slide#1width =175height =77/> ;
当从'main'目录内的gsp文件使用模板时,图像被加载。虽然,如果我在控制器内的gsp文件内使用相同的模板,则不会加载图像。我试图改变这种情况:
< img src =images / slide-1.jpgalt =Slide# 1width =175height =77/> b
< img src =../ images / slide-1.jpgalt =Slide#1width =175height =77/>
它可以工作,但是现在其他页面中的图像不会。任何想法来解决这个问题?我知道关键必须是绝对路径。但是我已经做了一些搜索,没有发现任何东西。
code> YOUR_PROJECT / web-app / images ),然后在gsp中通过资源标签。这样你就不会有绝对路径问题。对于一个具体的例子,你可以参考这个问题。
I have this image in my header template <img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
When the template is used from a gsp file inside the 'main' directory, the image is loaded. Although, if I have the same template being used inside a gsp file inside a controller, the image is not loaded. I have tried to change this:
<img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
to this:
<img src="../images/slide-1.jpg" alt="Slide #1" width="175" height="77" />
and it works, but now the image in the other page don't. Any idea to solve the problem? I know the key must be absolute path. But i've done some searches and found nothing.
You can put your images in resource folder (for example, in YOUR_PROJECT/web-app/images
) then access it in gsp by resource tag. By this way you won't have the absolute path problem.
For a concrete example, you can refer this question.
这篇关于grails图像的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!