NCNC

WTGGT,TTGG

用户操作
[即时聊天] [发私信] [加为好友]
张忠良ID:sunjavaduke
93440次访问,排名983好友0人,关注者2
优于别人,并不高贵,真正的高贵是优于昨天的自己
这个世界上最伟大的事情并不是已经取得的成就,而是前进的方向
sunjavaduke的文章
原创 10 篇
翻译 43 篇
转载 1 篇
评论 0 篇
sunjavaduke的公告
Contact me
最近评论
文章分类
收藏
    相册
    vic
    Favorite
    ASF
    存档
    订阅我的博客
    XML聚合  FeedSky

    翻译 JSF Tour Part2 Step to create JSF App收藏

    新一篇: JSF Tour Part3 Sun JSF Spec Notes | 旧一篇: JSF Tour Part1 Intro

     
    本文是对Sun网站的文章Developing Web Application with JavaServer Faces的翻译,如有转载,请声明出处!
     
    创建自定义的JSF Web应用程序
    1.     创建如下所示的目录结构:
    c:\jsf-1_1\samples\MyApp
                        \src
                           YourBeans.java
                        \web
                           YourJSP-pages.jsp
                           AnyImages.gif
                        \WEB-INF
                           web.xml
                           faces-config.xml
    2.     创建JSP页面和Bean类
    3.     根据需要修改web.xml和faces-config.xml文件
    4.     修改JavaServer Faces RI的发布包中的build.properties和build.xml文件,设置服务器的路径。以便使用Ant工具将工程打包发布。下面是一个build.xml文件的样例:
    <project name="MyFirst" default="build.war" basedir=".">
     <property file="../build.properties"/>
     <!-- Configure the context path for this application -->
     <property name="context.path" value="/jsf-MyFirst"/>
     <property name="example" value="jsf-MyFirst" />
     <property name="build" value="${basedir}/build" />
     <path id="classpath">
        <pathelement location="${commons-beanutils.jar}"/>
        <pathelement location="${commons-collections.jar}"/>
        <pathelement location="${commons-digester.jar}"/>
        <pathelement location="${commons-logging.jar}"/>
        <pathelement location="${jsf-api.jar}"/>
        <pathelement location="${jsf-impl.jar}"/>
        <pathelement location="${jstl.jar}"/>
        <pathelement location="${build}/${example}/WEB-INF/classes"/>
        <pathelement location="${servlet.jar}"/>
     </path>
     <target name="clean" >
        <delete dir="${build}" />
        <delete dir="${context.path}" />
     </target>
     <target name="prepare" description="Create build directories.">
        <mkdir dir="${build}/${example}" />
        <mkdir dir="${build}/${example}/WEB-INF" />
        <mkdir dir="${build}/${example}/WEB-INF/classes" />
        <mkdir dir="${build}/${example}/WEB-INF/lib" />
     </target>
     <!-- Executable Targets -->
     <target name="build" depends="prepare,deploy.copyJars"
         description="Compile Java files and copy static files." >
        <javac srcdir="src" destdir="${build}/${example}/WEB-INF/classes">
        <include name="**/*.java" />
         <classpath refid="classpath"/>
        </javac>
        <copy todir="${build}/${example}/WEB-INF">
            <fileset dir="web/WEB-INF">
            <include name="*.xml" />
          </fileset>
        </copy>
         <copy todir="${build}/${example}/">
          <fileset dir="web">
            <include name="*.html" />
            <include name="*.gif" />
            <include name="*.jpg" />
            <include name="*.jsp" />
            <include name="*.xml" />
          </fileset>
        </copy>
        <copy todir="${build}/${example}/WEB-INF/classes/${example}" >
          <fileset dir="web" >
             <include name="*properties"/>
          </fileset>
        </copy>
     </target>
     <target name="deploy.copyJars" if="build.standalone">
        <copy todir="${build}/${example}/WEB-INF/lib" file="${commons-beanutils.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${commons-collections.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${commons-logging.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${commons-digester.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${jsf-api.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${jsf-impl.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${jstl.jar}" />
        <copy todir="${build}/${example}/WEB-INF/lib" file="${standard.jar}" />
     </target>
     <target name="build.war" depends="build">
        <!-- create a war file for distribution -->
        <jar jarfile="${example}.war" basedir="${build}/${example}"/>
        <copy todir=".." file="${example}.war" />
        <delete file="${example}.war" />
     </target>
    </project>
    5.     根据需要修改上述的build.xml文件,然后运行ant命令,创建war文件。
    6.     war文件发布到应用程序服务器或者Servlet容器,启动服务。
    7.     使用URL:http://localhost:8080/yourApp访问web应用程序。

    发表于 @ 2008年06月10日 22:11:00|编辑|

    新一篇: JSF Tour Part3 Sun JSF Spec Notes | 旧一篇: JSF Tour Part1 Intro

    评论:没有评论。

    Csdn Blog version 3.1a
    Copyright © sunjavaduke