当前位置: 代码迷 >> Java Web开发 >> JSF 页面图片展示不出来
  详细解决方案

JSF 页面图片展示不出来

热度:584   发布时间:2016-04-17 12:37:51.0
JSF 页面图片显示不出来
为什么页面的背景图和button的图显示不出来, 路径是对的,在myeclipse中的design模式下也能看到,在Mozilla Priview 也显示正常,但在IE Priview也不能显示。发布到tomcat 5.5和IE Priview一样,显示不出来。不知道哪里有问题,请大虾帮帮忙。


<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="img/bgb.gif">
<h:form rendered="true" id="loginform">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
  <td >&nbsp;</td>
  <td width="883" height="473" align="left" valign="top" background="img/bg1.jpg" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td width="315" height="223">&nbsp;</td>
  <td width="272">&nbsp;</td>
  <td width="295">&nbsp;</td>
  </tr>
---------------------------------------------

 <td>
<h:commandButton id="loginbutton" rendered="true" image="img/sumit.jpg" action="#{userBean.loginAction}" type="submit"></h:commandButton>&nbsp;&nbsp;<h:commandButton rendered="true" id="cancelbutton" image="img/cancel.jpg" type="reset"></h:commandButton>
</td>


------解决方案--------------------
在显示不出来的图片位置点右键查看属性里的图片路径是否正确
把图片路径改成绝对路径试试:
<%
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<img src="<%=basePath%>/img/bg1.jpg">
------解决方案--------------------
直接用<img src="img/bg1.jpg" >能不能显示?
  相关解决方案