facelets+tomahawk+jsf环境配置

 

facelets+tomahawk+jsf 环境配置

 

 

先下载 facelets1.1.4 tomahawk1.1.6 jsf sun ri 1.2_08-b06-FCS 以及 tomahawk-facelets-taglib1.1.6

下面分别是它们的下载网站:

facelets1.1.4 https://facelets.dev.java.net/

tomahawk1.1.6: http://myfaces.apache.org/tomahawk/

jsf sun ri 1.2: http://java.sun.com/javaee/javaserverfaces/

tomahawk-facelets-taglib1.1.6: http://code.google.com/p/tomahawk-facelets/

 

jsf sun ri jsf 的参考实现,提供了 jsf 的基本功能和常用的组件, tomahawk 则是兼容于 jsf 规范并在其基础上提供了大量的扩展组件 ,facelets jsf 提供了强大的模板和方便地自定义组件的支持。为了将 tomahawk facelets 集成使用,需要将 tomahawk-facelets-taglib 放到 WEB-INF/lib 目录下即可。 tomahawk 依赖很多第三方的 jar 包,可以参照 tomahawk-example 中的 WEB-INF/lib 目录,将这些依赖的包也放在项目 WEB-INF/lib 路径下。如图 :

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

web.xml 文件的配置 :

 

<? xml version = '1.0' encoding = 'UTF-8' ?>

 

<! DOCTYPE web-app PUBLIC

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" >

 

 

< web-app >

 

<!-- facelets -->

< context-param >

    < param-name > javax .faces.DEFAULT_SUFFIX </ param-name >

    < param-value > . xhtml </ param-value >

</ context-param >

 

<!-- Faces Servlet -->

< servlet >

    < servlet-name > FacesServlet </ servlet-name >

    < servlet-class > javax .faces. webapp .FacesServlet </ servlet-class >

    < load-on-startup > 1 </ load-on-startup >

</ servlet >

 

<!-- Faces Servlet Mapping -->

< servlet-mapping >

    < servlet-name > FacesServlet </ servlet-name >

    < url-pattern > *. jsf </ url-pattern >

</ servlet-mapping >

<!-- tomahawk -->

< filter >

    < filter-name > MyFacesExtensionsFilter </ filter-name >

    < filter-class >

       org . apache . myfaces . webapp .filter.ExtensionsFilter

    </ filter-class >

    < init-param >

         < param-name > uploadMaxFileSize </ param-name >

         < param-value > 20m </ param-value >

         < description > Set the size limit for uploaded files.

           Format: 10 - 10 bytes

                           10k - 10 KB

                           10m - 10 MB

                            1g - 1 GB

          </ description >

      </ init-param >

</ filter >

 

<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->

< filter-mapping >

   < filter-name > MyFacesExtensionsFilter </ filter-name >

      <!-- servlet -name must match the name of your javax .faces. webapp .FacesServlet entry -->

   < servlet-name > FacesServlet </ servlet-name >

</ filter-mapping >

<!-- extension mapping for serving page-independent resources ( javascript , stylesheets , images, etc.) -->

< filter-mapping >

   < filter-name > MyFacesExtensionsFilter </ filter-name >

   < url-pattern > /faces/myFacesExtensionResource/* </ url-pattern >

</ filter-mapping >

<!-- custom component -->

< context-param >

     < param-name > facelets .LIBRARIES </ param-name >

     < param-value >

         /WEB-INF/mycustom .taglib .xml

     </ param-value >

</ context-param >

 

</ web-app >

 

可以不使用 tomahawk-facelets-taglib.jar ,而是手动编写 tomahawk.taglib.xml 组件描述文件并在 web.xml 中将路径告知 facelets, 即设置参数 facelets .LIBRARIES 的值。

 

faces-config .xml 文件的配置 :

< faces-config >

<!-- facelets -->

< application >

    < view-handler >

          c om.sun.facele ts.FaceletViewHandler

    </ view-handler >

</ application >

<!-- navigation -->

<!-- back bean -->

 

</ faces-config >

 

完成上述配置后,就可以发挥 jsf tomahawk facelets 的强大功能了 , 开发的项目可以在 tomcat6.0.16 中运行,也可以使用其它的服务器。

 

 

 

 

你可能感兴趣的:(Web,xml,servlet,JSF,sun)