我正在经历将我们的应用程序从 JEE5/Icefaces 1.8.2 升级到 JEE6/Icefaces 3.3 的练习。我遵循了我在这里找到的材料: 从 JSF 1.2 迁移到 JSF 2.0 以及提供的 Icefaces:http: //www.icesoft.org/wiki/display/ICE/ICEfaces+1.x+Compatibility
所以现在我可以成功地将我们的应用程序部署到 GlassFish 3。
这是 web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>pdb</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<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-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>
<context-param>
<param-name>org.icefaces.ace.theme</param-name>
<param-value>rime</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>604800</param-value>
</context-param>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/index.html</location>
</error-page>
<!-- ICE FACES ADDED -->
<!-- Facelets Custom Components -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/facelets/imsref_common_taglib.xml;/WEB-INF/facelets/imsref_pdb_taglib.xml</param-value>
</context-param>
<listener>
<listener-class>LifeCycleListener</listener-class>
</listener>
<filter>
<filter-name>RedirectFilter</filter-name>
<filter-class>RedirectFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RedirectFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Transactions</filter-name>
<filter-class>TransactionalFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Transactions</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>60</session-timeout>
</session-config>
<!--Security Settings-->
<login-config>
<auth-method>FORM</auth-method>
<realm-name>pdb-auth-realm</realm-name>
<form-login-config>
<form-login-page>/login.jsf</form-login-page>
<form-error-page>/loginerror.jsf</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>pdb</web-resource-name>
<url-pattern>/secure/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<!--Security constraint so only admin role can access the monitoring page-->
<security-constraint>
<web-resource-collection>
<web-resource-name>monitoring</web-resource-name>
<url-pattern>/monitoring</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<description>Administrator. Is the super-user. Can do everything. This role includes all other roles.</description>
<role-name>admin</role-name>
</security-role>
<mime-mapping>
<extension>aspx</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>png</extension>
<mime-type>image/png</mime-type>
</mime-mapping>
</web-app>
现在当我导航到
https://localhost:8181/pdb/secure/main.jspx
我被重定向到登录页面,但只加载了 jsf 组件。没有任何 .css 被加载,当我导航到资源时,来自服务器的响应始终是 Content-Length “0”,但状态为 200。任何图像都一样。
当我对我们的领域进行身份验证时,我可以在 /pdb/ 之后输入任何 URL(即任何垃圾 URL,例如)
https://localhost:8181/pdb/somenonexistantpage
服务器响应 200 OK 和 Content-Length "0"
应用程序的结构如下:
WEB-INF\login.xhtml
WEB-INF\index.xhtml
WEB-INF\loginerror.xhtml
WEB-INF\css\<custom css>
WEB-INF\resources\components\<components>
WEB-INF\resources\images\<images>
WEB-INF\resources\icons\<icons>
WEB-INF\secure\<all .xhtml jsf pages>
GET 请求:
https://localhost:8181/pdb/xmlhttp/css/rime/rime.css
仅返回以下内容:
Content-Length:"0"
Date:"Tue, 19 Nov 2013 19:31:32 GMT"
Server:"GlassFish Server Open Source Edition 3.1.2.2"
X-Powered-By:"Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)"