2010-08-30 58 views
0

我已經創建了一個新的Web項目並在MyEclipse上啓用了它的JSF和Facelets功能,然後我通過weblogic部署了它。一切看起來都很好,但它對我來說不起作用,似乎視圖處理程序根本沒有被調用。它有什麼問題?任何人都可以幫我嗎?如何使facelets工作?

這是我web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 
    <context-param> 
     <param-name>javax.faces.CONFIG_FILES</param-name> 
     <param-value>/WEB-INF/faces-config.xml</param-value> 
    </context-param> 
    <context-param> 
     <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
     <param-value>.xhtml</param-value> 
    </context-param> 
    <context-param> 
     <param-name>facelets.VIEW_MAPPINGS</param-name> 
     <param-value>*.xhtml</param-value> 
    </context-param> 
    <context-param> 
     <param-name>facelets.DEVELOPMENT</param-name> 
     <param-value>true</param-value> 
    </context-param> 
    <servlet> 
     <servlet-name>Faces Servlet</servlet-name> 
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
     <load-on-startup>0</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.faces</url-pattern> 
    </servlet-mapping> 
    <servlet-mapping> 
     <servlet-name>Faces Servlet</servlet-name> 
     <url-pattern>*.jsf</url-pattern> 
    </servlet-mapping> 
</web-app> 

這是我faces-config.xml項:

<application> 
    <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> 
    <locale-config> 
     <default-locale>en</default-locale> 
    </locale-config> 
</application> 

這是我簡單xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xml:lang="en" lang="en"> 
    <head> 
     <title>My Facelets Page</title> 
     <meta http-equiv="keywords" content="enter,your,keywords,here" /> 
     <meta http-equiv="description" content="A short description of this page." /> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
     <!--<link rel="stylesheet" type="text/css" href="styles.css">--> 
    </head> 
    <body> 
     <p> 
      <ui:insert name="body">This is my JavaServer Facelets page.</ui:insert> 
     </p> 
    </body> 
</html> 
+0

請向我們展示至少您的'web.xml'和您的一個facelets模板:) – 2010-08-30 08:10:12

+0

對不起,我編輯了我的文章。 – arash 2010-08-30 08:46:08

回答

0

如果你不發生這種情況t請求通過第url-pattern頁的頁面e FacesServlet。確保您的請求URL是正確的。即打開頁面http://example.com/context/page.jsf,因此不打印http://examlpe.com/context/page.xhtml

如果這沒有幫助,那麼第一個下一步就是讀取服務器日誌中是否有任何錯誤或警告。

+0

謝謝它的作品:) – arash 2010-08-30 11:29:38

+0

不客氣。順便說一句,你不使用JSF 2.0的任何原因?這些配置設置對於JSF 1.2是典型的。 – BalusC 2010-08-30 11:31:48