我写了一个liferay richfaces portlet。但我无法获取 web-inf 文件夹中的 css 路径或图像。我的 portlet 配置是
<portlet>
<portlet-name>testLR6_PB3_RF4</portlet-name>
<instanceable>true</instanceable>
<render-weight>1</render-weight>
<ajaxable>true</ajaxable>
<header-portlet-css>/resources/css/style.css</header-portlet-css>
<header-portlet-javascript>/js/eims.js</header-portlet-javascript>
<footer-portlet-javascript>/js/fileupload.js</footer-portlet-javascript>
</portlet>
在我的 jsf 页面中
<link href="${facesContext.externalContext.requestContextPath}/resources/css/style.css" rel="stylesheet" type="text/css" />
<div class="floatleft1"><img src="${facesContext.externalContext.requestContextPath}/resources/images/eims_logo.jpg" /></div>
如何获取资源路径。
这是我的 java servletcontext 代码
FacesContext context = FacesContext.getCurrentInstance();
ServletContext servletContext= (ServletContext) context.getCurrentInstance().getExternalContext().getContext();
String path=servletContext.getRealPath("/");
MainBean mainBean = new MainBean();
mainBean.getUserBean().setUserPath(path);