從 JSF 1.2 升級到 JSF 2.0 的痛苦
從 JSF 1.2 升級到 2.0 的痛苦取決於您目前使用的視圖技術和未來。這取決於您計劃使用的查看技術。
- JSP 2.x 到 JSP 2.x = 幾乎不費力。
- Facelets 1.x 到 Facelets 2.0 = 更少的工作量。
- JSP 2.x 到 Facelets 2.0 = 大量工作。如果您有自訂元件,則需要加倍。
基本變更
無論切換視圖技術如何,您至少應該執行以下步驟:
- 從/WEB-INF/lib(如果存在)中刪除JSF 1.2 JAR。
- 將 JSF 2.0 JAR 拖放到 /WEB-INF/lib 中(如果 JSF 1.2 由 servlet 容器提供,請設定類別以在 servlet 容器的庫之前先載入 Web 應用程式庫)。策略(另請參閱應用程式伺服器 JSF2 類別載入問題)。
- 更新 faces-config.xml 中的根宣告以符合 JSF 2.0 規格。
<faces-config 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-facesconfig_2_0.xsd" version="2.0"></faces-config>
注意:如果您使用的是JSF 2.2 或更高版本,請在上面的XML 程式碼段中使用http://xmlns.jcp 而不是http://java. sun.com。 .org 命名空間域。
- 確保 web.xml 中的路由宣告至少符合 Servlet 2.5。 JSF 2.0 在 2.4 以下將無法運作(儘管駭客是可能的)。
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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"></web-app>
注意:如果您使用的是Servlet 3.0 或更高版本,請在上面的XML 程式碼段中使用http://xmlns.jcp 而不是http://java. sun.com。 .org 命名空間域。
JSP 2.x 到 JSP 2.x
如果您使用的是 JSP 2。基本上您不需要更改任何其他內容。 逐步升級
如果您已經在FacesServlet 中使用後綴URL 模式(例如.jsf)並且想要
只使用,FacesServlet 首先會掃描只使用,FacesServlet 首先會掃描只使用,FacesServlet 首先會掃描
只使用,FacesServlet 首先會掃描只使用,FacesServlet 先掃描.xhtml 文件,如果不存在,則為*.jsp記住掃描文件是個好主意。這允許從 JSP 逐步轉換到 Facelets,而無需更改 URL。但是,如果您使用前綴URL 模式(例如/faces/)並希望分階段從JSP 升級到Facelets,請將其更改為.jsf 並可能替換現有的所有連結JSP頁面也必須改變。
請注意,新的 JSF 2.0 提供的隱式導航不會掃描檔案是否存在,而是導航到結果.xhtml。因此,如果您從 .jsp 移動到 .jsp,您仍然需要以 JSF 1.x 方式將其包含在視圖 ID 中。
Facelets 1.x 到 Facelets 2.0
我使用 Facelets 1.x 作為我的視圖技術,Facelets 2.x 作為我的視圖技術,
Facelets 2.0- 作為我的視圖技術,
- Facelets 2.0
- 從 /WEB-INF/lib 中刪除 Facelets 1.x JAR。
- Facelets 1.x 從 faces-config.xml 中刪除 FaceletViewHandler。
- 如果您有自訂 FaceletViewHandler 實現,則必須更新它以擴展 ViewHandlerWrapper。
- 儘管沒有必要,但出於清理目的,請從 web.xml 中刪除 Facelets 1.x 相關的
值(例如, javax.faces.DEFAULT_SUFFIX 值為 *.xhtml)。這已經是 Facelets 2.0 中的預設值。
<faces-config 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-facesconfig_2_0.xsd" version="2.0"></faces-config>將現有 Facelet 標籤庫 XML 的根聲明更新為相容 Facelet 2.0。 注意:如果您使用的是JSF 2.2 或更高版本,請在上面的XML 程式碼段中使用http://xmlns.jcp 而不是http://java. sun.com。 .org 命名空間域。 這些基本上就夠了。
JSP 2.x 到Facelets 2.0 我們正在使用JSP 2.x
作為我們的視圖技術,並將很快升級到Facelets 2.0
如果如果您願意,您必須在發佈網站之前進行大量更改。我們基本上改變了這裡的視圖技術。 母版頁修改<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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"></web-app>
必須在所有母版頁中修改以下基本 JSP 範本。
<facelet-taglib 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-facelettaglibrary_2_0.xsd" version="2.0"></facelet-taglib>
改為以下基本 Facelets 範本。
注意:如果您使用的是JSF 2.2 或更高版本,請在上面的XHTML 程式碼段中使用http://xmlns.jcp.org 名稱而不是http://java. sun.com。空間域。包含頁面變更
如果您現有的JSP 頁面設計良好,則不會有scriptlet 行程式碼,唯一的JSP 特定標記將是
jsp 應該只有是:包括>它們應該從:<faces-config 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-facesconfig_2_0.xsd" version="2.0"></faces-config>更改如下。
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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"></web-app>基本 JSP 包含頁面範本...
<facelet-taglib 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-facelettaglibrary_2_0.xsd" version="2.0"></facelet-taglib>...必須變更為以下基本 Facelets 包含頁面範本。
<view> <title>JSP page</title> <outputtext value="JSF components here."></outputtext> </view>
以上是從 JSF 1.2 遷移到 JSF 2.0 面臨哪些挑戰?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

JavaachievesPlatFormIndependencethroughTheJavavIrtualMachine(JVM),允許Codetorunondifferentoperatingsystemsswithoutmodification.thejvmcompilesjavacodeintoplatform-interploplatform-interpectentbybyteentbytybyteentbybytecode,whatittheninternterninterpretsandectectececutesoneonthepecificos,atrafficteyos,Afferctinginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginging

JavaispoperfulduetoitsplatFormitiondence,對象與偏見,RichstandardLibrary,PerformanceCapabilities和StrongsecurityFeatures.1)Platform-dimplighandependectionceallowsenceallowsenceallowsenceallowsencationSapplicationStornanyDevicesupportingJava.2)

Java的頂級功能包括:1)面向對象編程,支持多態性,提升代碼的靈活性和可維護性;2)異常處理機制,通過try-catch-finally塊提高代碼的魯棒性;3)垃圾回收,簡化內存管理;4)泛型,增強類型安全性;5)ambda表達式和函數式編程,使代碼更簡潔和表達性強;6)豐富的標準庫,提供優化過的數據結構和算法。

javaisnotirelyplatemententedduetojvmvariationsandnativecodinteinteration,butitlargelyupholdsitsitsworapromise.1)javacompilestobytecoderunbythejvm

thejavavirtualmachine(JVM)IsanabtractComputingmachinecrucialforjavaexecutionasitrunsjavabytecode,使“ writeononce,runanywhere”能力

Javaremainsagoodlanguageduetoitscontinuousevolutionandrobustecosystem.1)Lambdaexpressionsenhancecodereadabilityandenablefunctionalprogramming.2)Streamsallowforefficientdataprocessing,particularlywithlargedatasets.3)ThemodularsystemintroducedinJava9im

Javaisgreatduetoitsplatformindependence,robustOOPsupport,extensivelibraries,andstrongcommunity.1)PlatformindependenceviaJVMallowscodetorunonvariousplatforms.2)OOPfeatureslikeencapsulation,inheritance,andpolymorphismenablemodularandscalablecode.3)Rich

Java的五大特色是多態性、Lambda表達式、StreamsAPI、泛型和異常處理。 1.多態性讓不同類的對象可以作為共同基類的對象使用。 2.Lambda表達式使代碼更簡潔,特別適合處理集合和流。 3.StreamsAPI高效處理大數據集,支持聲明式操作。 4.泛型提供類型安全和重用性,編譯時捕獲類型錯誤。 5.異常處理幫助優雅處理錯誤,編寫可靠軟件。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具