首页 \ 问答 \ grails图像的绝对路径(grails images absolute path)

grails图像的绝对路径(grails images absolute path)

我在我的标题模板中有这个图像<img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />

当从'main'目录内的gsp文件使用模板时,图像被加载。 虽然,如果我在控制器内的gsp文件内使用相同的模板,则不会加载图像。 我试图改变这一点:

<img src="images/slide-1.jpg" alt="Slide #1" width="175" height="77" />

对此:

<img src="../images/slide-1.jpg" alt="Slide #1" width="175" height="77" />

它可以工作,但现在其他页面中的图像不会。 任何想法来解决这个问题? 我知道关键必须是绝对路径。 但我做了一些搜索,没有发现任何东西。


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.


原文:https://stackoverflow.com/questions/5944393
更新时间:2023-10-27 07:10

最满意答案

如果您尝试在界面构建器中的代码中重新创建接口,则需要查看Size Inspector:

首先,在界面构建器中选择一个元素:

在此处输入图像描述

现在查看右侧面板中的Size Inspector:

在此处输入图像描述

X,Y,Width和Height变量为您提供足够的信息来创建与元素大小相同的CGRect

CGRect editFrame = CGRectMake(233.0, 6.0, 67, 32);

If you're trying to recreate an interface in code that's in interface builder, you need to look at the Size Inspector:

First, select an element in interface builder:

enter image description here

Now look at the Size Inspector in the right-side panel:

enter image description here

The X, Y, Width and Height variables give you enough information to create a CGRect with the same size as the element:

CGRect editFrame = CGRectMake(233.0, 6.0, 67, 32);

相关问答

更多
  • 原因是 ”?” (questionmark)中的项目名称(也许有与其他符号的错误 - 没有检查它)。 你可以尝试重新命名项目,或只是创建一个名称不带“?”的新项目。 在里面。 The reason is "?" (questionmark) in Project's name (maybe there is a bug with other symbols – didn't check it). You can try to rename Project or just create new one wit ...
  • 我们发布了一个新版本,应该通过热门词汇样本解决语言选择问题: https ://pypi.python.org/pypi/google-assistant-sdk/0.4.1 你可以再次尝试使用错误报告中的说明吗? https://github.com/googlesamples/assistant-sdk-python/issues/146#issuecomment-354217352 We published a new release that should address the language ...
  • 如果您尝试在界面构建器中的代码中重新创建接口,则需要查看Size Inspector: 首先,在界面构建器中选择一个元素: 现在查看右侧面板中的Size Inspector: X,Y,Width和Height变量为您提供足够的信息来创建与元素大小相同的CGRect : CGRect editFrame = CGRectMake(233.0, 6.0, 67, 32); If you're trying to recreate an interface in code that's in interface ...
  • 说“好吧,Google - 用[您的应用]做[某些事]”,以便打开您的应用来完成查询,这称为Google语音操作,您可以轻松地将这些添加到您的应用中。 有关完整的详细信息,请参阅文档。 请注意 - 为了使这些工作起作用,您的应用程序必须位于Play商店中,并至少作为测试版上传。 Google智能助理有点不同 - 它更具有对话性,并且不会将用户直接带到您的应用中。 相反,它需要用户输入,查找适当的应用程序来处理查询,将查询提供给您的应用程序,然后在Google智能助理内部返回响应。 这完全是关于通过Googl ...
  • 可以使用第三方库,如JWebDAV for Exchange 对于Exchange 2003,请使用“JWebDAV for Exchange”。 例子: http://www.independentsoft.de/jwebdav/tutorial/getfreebusyforspecifiedusers.html 对于Exchange 2007/2010/2013,请使用“JWebServices for Exchange”。 例子 http://www.independentsoft.de/jwebse ...
  • 从根本上说,函数是一个Express.js服务器,但不会让您了解Express的所有配置选项。 你有几个选择。 最简单的是在你的函数中明确地调用中间件本身。 来自Google的文档 : 如果您需要为cookie支持或CORS等内容注入中间件依赖项,请在函数中调用它们。 例如,要启用CORS支持,请添加以下块: // Enable CORS using the `cors` express middleware. cors(req, res, () => { // ... }); 还有更复杂的方法来挂钩 ...
  • 创建新项目时,在“ Migrate To下拉框中指定目标数据库版本。 默认值为SQL Azure 。 我怀疑你没有检查下拉列表并创建了一个默认值的项目。 如果选择其他版本,例如SQL Server 2016或SQL Server 2014 ,则可以使用“ Connect to SQL Server按钮。 When you create a new project you specify the target database version in the Migrate To dropdown box. T ...
  • 我相信这是3.2.0GA SDK中的一个错误(3.2.1和3.3.0尚未正式发布)。 据我所知,它已知并应在下一次SDK更新中修复。 唯一的问题是此更新何时结束。 您可以通过恢复到3.1.3GA获得内容辅助,但如果您需要3.2.0GA的功能,这对您没有多大帮助。 编辑:该问题在本JIRA票据中有所描述,因为它应该在即将发布的3.2.1版本中得到解决。 I believe this is a bug in the 3.2.0GA SDK (3.2.1 and 3.3.0 are not official re ...
  • 在entry_changed ,你必须调用gtk_entry_set_text(GTK_ENTRY(page[2].widget), name); 再次,因为你只设置一次条目文本,这是唯一重要的事情。 否则,您在设置第3页时设置的默认值会粘住。 in entry_changed, you will have to call gtk_entry_set_text(GTK_ENTRY(page[2].widget), name); again, as you only set the entry text on ...
  • 有一个技巧,你可以尝试。 这是代码: let item = self.yourTextView.inputAssistantItem; item.leadingBarButtonGroups = []; item.trailingBarButtonGroups = []; There is a trick that you can try. Here is the code: let item = self.yourTextView.inputAssistantItem; item.leadingBarB ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。