通过jsf从外部位置显示图像 [英] Display image from external location by jsf

查看:84
本文介绍了通过jsf从外部位置显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了有关同一问题的文章,"tomcat服务器"端的解决方案是在element内添加element以及我的操作:

I read number of posts about the same issue and the solution from the "tomcat server" side is to add element inside element and what i did like this :

<Host>
    <Context docBase="path_to_image" path="/images" />
.....

我现在的问题是,如果我尝试通过html image标签显示图像:

My issue now is that if i tried to display the image by html image tag like that :

<img src="/images/dist/image_name.ext"/>

呈现的图像没有任何问题,但是使用jsf标记时出现问题:

the image rendered without any problem , but i have aproblem when use the jsf tag like :

<h:graphicImage value="/images/dist/image_name.ext" />

此标记的输出为:[http://localhost:8080/context_name/faces/images/dist/image_name.ext]

this tag's output is : [http://localhost:8080/context_name/faces/images/dist/image_name.ext]

所以我认为如果我可以从jsf组件指向[http://localhost:8080/images/dist/image_name.ext],它将解决此问题,但是我该怎么做呢?

so i think if i can point to [http://localhost:8080/images/dist/image_name.ext] from the jsf component it will solve the issue but how can i make this ?

有什么主意吗?

我看到了这篇文章 http://balusc.blogspot.com/2007/04/imageservlet.html

但是如果我能像我之前提到的那样通过server.xml解决该问题,那就更好了.

but it will be betterif i can solve that issue by the server.xml as i mentioned before .

推荐答案

<h:graphicImage>确实将webapp上下文路径隐式地置于图像URL的前面.只是不要使用它并坚持纯HTML <img>元素.无论您出于什么原因而需要将其作为<h:graphicImage>组件,都需要重新考虑或解决,以使您可以继续使用纯HTML <img>.元素.

The <h:graphicImage> will indeed implicitly prepend the webapp context path to image's URL. Just don't use it and stick to plain HTML <img> element. Whatever reason you've in mind which would require it to be a <h:graphicImage> component needs to be reconsidered or solved differently so that you can keep using plain HTML <img>. element.

这篇关于通过jsf从外部位置显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆