0

我正在学习如何使用 icefaces,所以我使用 icefaces wiki 教程创建了一些简单的应用程序。问题是附加到 jsf 页面的 css 不可见(尝试打开 css 地址后出现错误 404)。根据这里的icefaces信息

To use a predefined theme style sheet with an ICEfaces application, all the page developer needs to do is add the desired CSS link to the page. [...]

<ice:outputStyle href="./xmlhttp/css/xp/xp.css" rel="stylesheet" type="text/css" />
Note: In the examples above, the xmlhttp/css/xp/ path is automatically resolved by ICEfaces and all needed resources are loaded from the ICEfaces.jar. 

我已经<ice:outputStyle>像这样添加到我的 jsf 页面中:

<h:head>
        <ice:outputStyle href="./xmlhttp/css/xp/xp.css" rel="stylesheet" type="text/css" />
</h:head>

我使用 gradle 创建了项目,这些是项目使用的依赖项(从 maven 中央仓库下载):

dependencies {
    compile 'javax.servlet:servlet-api:2.5'
    compile 'com.sun.faces:jsf-api:2.2.2'
    compile 'com.sun.faces:jsf-impl:2.2.2'
    compile 'org.icefaces:icefaces:3.3.0'
    compile 'org.icefaces:icefaces-compat:3.3.0'
    compile 'org.icefaces:icefaces-ace:3.3.0'
}
4

1 回答 1

1

您需要为 in 添加以下 servlet 映射CompatResourceServletweb.xml使兼容性组件正常工作。

 <!-- Many of the ICEfaces Components make use of the Resource Servlet -->
<servlet>
    <servlet-name>Resource Servlet</servlet-name>
    <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- These specific mappings are necessary for the Resource Servlet to function properly -->
<servlet-mapping>
    <servlet-name>Resource Servlet</servlet-name>
    <url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
于 2013-09-25T04:01:58.897 回答