如何显示玻璃鱼文件夹中的图像? [英] How to display images located in glass fish folder?
问题描述
我正在使用JSF和glassfish 4.0.我知道可以直接访问放置在项目资源文件夹下的images目录中的所有图像.我想知道如何显示玻璃鱼文件夹中的图像.我在玻璃鱼域下创建了一个图像文件夹,并希望在JSF页面中显示此图像.谁能让我知道我该怎么做?我对此很陌生,因此需要一些帮助.
I am using JSF and glassfish 4.0. I know that all the images that are placed in images directory under the resources folder of the project can be accessed directly. I wanted to know how I can display images which are located in glass fish folder.I created a images folder under glass fish domains and I want to display this images in the JSF page. Could anyone let me know how I can do that? I am new to this so need some help.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<property name="alternatedocroot_1" value="from=/images/* dir=/test/webapp" />
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>
Keep a copy of the generated servlet class' java code.
</description>
</property>
</jsp-config>
</glassfish-web-app>
JSF页面:
<header>
<h:graphicImage id="banner" style="width:700px;height: 52px;"
value="/images/header.jpg" />
</header>
推荐答案
根据评论,
我尝试将其添加到
glassfish-web.xml
<property name="alternatedocroot_1" value="from=/images/* dir=/test/webapp/images" />
假设您使用的Windows在C:\
上安装了GlassFish,则此特定配置需要其中包含所有图像的文件夹C:\test\webapp\images\images
.
Assuming that you're using Windows with GlassFish installed on C:\
, then this specific configuration expects a folder C:\test\webapp\images\images
with all the images therein.
如果您实际上有一个文件夹C:\test\webapp\images
,则应按以下方式进行配置:
If you actually have a folder C:\test\webapp\images
, then you should be configuring as follows:
<property name="alternatedocroot_1" value="from=/images/* dir=/test/webapp" />
还请注意,相对于GlassFish安装文件夹或Webapp的部署空间,这绝对没有任何关系,因此我在glass fish域下创建了一个图像文件夹" 这样行不通.
Also note that this is absolutely not in any way relative to the GlassFish installation folder or the webapp's deploy space, so "I created a images folder under glass fish domains" as per the question would absolutely not work this way.
如果实际上有一个C:\path\to\glassfish\domains\test\webapp\images
文件夹,则应按以下方式对其进行配置:
If you actually have a C:\path\to\glassfish\domains\test\webapp\images
folder, then you should be configuring it as follows:
<property name="alternatedocroot_1" value="from=/images/* dir=/path/to/glassfish/domains/test/webapp" />
另请参见:
- 从Web应用程序外部加载图像/webcontext/使用< h:graphicImage>部署文件夹或< img>标签
- 如何将文件写入应用程序的resource/images文件夹?
- Load images from outside of webapps / webcontext / deploy folder using <h:graphicImage> or <img> tag
- How to write a file to resource/images folder of the app?
See also:
更新:根据您随后在问题中编辑的glassfish-web.xml
内容,不应将<property>
放入<jsp-config>
,但必须是
Update: as per the glassfish-web.xml
contents which you edited in your question afterwards, that <property>
shouldn't go in <jsp-config>
, but needs to be an immediate child of <glassfish-web-app>
.
这篇关于如何显示玻璃鱼文件夹中的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!