从struts2动作变量的路径在jsp显示图像
问题说明
我有一个 struts2 动作,它有一个我想在 jsp 页面中显示的图像的变量.当我使用以下内容显示变量的值时:
i have a struts2 action which has a variable for an image which i want to display in a jsp page. when i display the value of the variable using the following:
<s:property value="variableName" />
我得到图像文件的绝对路径.
i get the absolute path of the image file.
但是当我尝试以下操作时:
but when i try the following:
<img src='https://www.it1352.com/<s:property value="variableName" />' />
我在那里得到一个空白.我什至尝试过以下方法:
i get a blank there. i have even tried the following:
<img src="https://www.it1352.com/${variableName}" />
我做了一些思考.设置的图像路径在tomcat的临时文件夹中.是因为我无法访问它吗?
i have done some thinking. the path of the image which is set is in temp folder of tomcat. is it because of that that i am unable to access it?
没有效果.这可能是什么问题?
to no effect. what may be the issue in this?
正确答案
img
标签的src
必须包含绝对路径,才能指向来自客户端计算机的图像文件.
The src
of the img
tag must contain an absolute path, then only it can point to the image file from the client machine.
如果variableName
包含这样的绝对路径
If the variableName
contains an absolute path like this
http://localhost/images/pics/icon.gif
img
将从服务器中找到图像.因此始终可用,因此您可以使用它.
The img
will finds the image from the server. Thus available always an hence you can use this.
<img src="https://www.it1352.com/${variableName}"/>
如果 variableName
是一个相对路径,即;服务器可识别的东西.
If the variableName
is a relative path ie; something that's recognisable for the server.
/images/pics/icon.gif
上述路径将由服务器识别,但不会从远程机器识别.在这种情况下,你需要有这个
The above path will be identified by the server but it wont be identified from the remote machine. In that case you need to have this
<img src="https://www.it1352.com/<c:url value=variableName/>" />
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcbcceg
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20