证书在线制作:Apache myfaces介绍和配置2

来源:百度文库 编辑:九乡新闻网 时间:2024/05/03 22:44:49

Apache myfaces介绍和配置

JSF是一个新的基于MVC模型的web应用框架技术。在概念和特征方面,尤其是组件方面,超过了著名的Struts框架。而myfaces是Apache软件基金的一个项目,它实现了JSF框架。同样sun公司也有一个参考实现 JSF RI。但是myfaces比JSF RI提供了更多的组件和特征。
可以参考:http://myfaces.apache.org/index.html 
http://java.sun.com/j2ee/javaserverfaces/
开发基于JSF的web应用程序可以使用下列IDE(笔者已知):
myEclipse(Eclipse插件)  ,默认同时支持JSF RI 和myfaces
http://www.myeclipseide.com/
Exadel(Eclipse插件)  默认支持JSF RI
http://www.exadel.com/
Java Studio Creator 默认支持JSF RI
oracle 的jDevelop 也支持JSF但是有自己的特色组件。

使用myfaces
myfaces官方的发行版本myfaces1.1.0中有四个jar包,分别 myfaces-api.jar,myfaces-impl.jar,tomahawk.jar,myfaces-all.jar。myfaces-all.jar包括了前三个jar包的所有

内容。myfaces-api.jar,其实是JSF RI。tomahawk.jar是包含了myfaces实现的特色组件,可以单独使用,在已经使用JSF的web应用程序中加入这个包就可以myfaces的组件,但是

无法使用myfaces的其他特征,如和struts-tiles结合。
笔者在myeclipse,tomcat5.0.28和jdk1.4.2中成功运行基于myfaces的web应用程序。并且没用了笔者以前提到的JSF中文输入乱码的问题。但是在tomcat5.5.9和JDK1.5update4中

没用调试成功,tomcat启动报错,页面无法显示。在web\lib下加入myfaces的jar包后,还要在web.xml中加入如下片断。


xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
    javax.faces.CONFIG_FILES
    /WEB-INF/faces-config.xml
 

 
    org.apache.myfaces.webapp.StartupServletContextListener
 

 
 
        extensionsFilter
       
                org.apache.myfaces.component.html.util.ExtensionsFilter
       

       
               
                        Set the size limit for uploaded files. Format: 10 - 10
                        bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
               

                uploadMaxFileSize
                100m
       

       
               
                        Set the threshold size - files below this limit are
                        stored in memory, files above this limit are stored on
                        disk.
                        Format: 10 - 10 bytes 10k - 10 KB 10m - 10 MB 1g - 1 GB
               

                uploadThresholdSize
                100k
       

    


        extensionsFilter
        *.faces


        extensionsFilter
        /faces/*

 
 
    Faces Servlet
    javax.faces.webapp.FacesServlet
    0
 

 
    Faces Servlet
    *.faces
 

 


要在页面使用myfaces组件,请在页面中加入。
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

参考:
http://wiki.apache.org/myfaces/How_to_add_MyFaces_support_to_a_Sun_JSF_RI_application
http://wiki.apache.org/myfaces/Installation_and_Configuration
http://myfaces.apache.org/index.html
http://myfaces.apache.org/gettingstarted.html