<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    all gone

    all gone

    Eclipse下JSF入門

    1.開發(fā)環(huán)境
       與Eclipse下Struts的開發(fā)類似,安裝好Eclipse和Tomcat之后,還需要兩個(gè)插件:tomcat 插件和JSF插件(如果相關(guān)插件還沒有安裝),以下是相關(guān)下載地址:
        Eclipse SDK:
            http://www.eclipse.org/downloads/index.php 
        JSF:
         https://sourceforge.jp/projects/amateras/files/  
          FaceIDE+htmlEditor,htmlEditer也是必要的
        Tomcat :
             http://www.sysdeo.com/eclipse/tomcatplugin 
        Plugin Search:
             http://eclipse-plugins.2y.net/eclipse/search.jsp 
       插件的安裝和配置有問題請(qǐng)直接Google。
    2.開始
        入門嘛,我們就找一個(gè)最簡(jiǎn)單的Login就可以了

        新建Tomcat project
        加入JSF支持

        新建一個(gè)ManagedBean:


    /**
     *
     */
    package com.jsf;




    /**
     * @author lzy
     *
     */
    public class UserBean {
    private String name;
        private String password;
    public String verify() {
         if(this.name.equals("name")&&this.password.equals("password"))
         
            return "failure";

       else
            return "success";
    }

     
    /**
    * @return Returns the name.
    */
    public String getName() {
    return name;
    }

    /**
    * @param name The name to set.
    */
    public void setName(String name) {
    this.name = name;
    }


    /**
    * @return Returns the password.
    */
    public String getPassword() {
    return password;
    }

    /**
    * @param password The password to set.
    */
    public void setPassword(String password) {
    this.password = password;
    }


    }

         新建兩個(gè)JSP頁(yè)面,login.jsp,welcom.jsp

    login.jsp
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <link href="main.css" rel="stylesheet"/>
    <title></title>

    </head>
    <body>
        <f:view>
        <f:loadBundle basename="com.jsf.MessageResources" var="msgs"></f:loadBundle>
       
            <h:form>
            <h:panelGrid columns="3" headerClass="header" rowClasses="evenRow,oddRow">
            <f:facet name="header" >
            <h:outputText value="#{msgs.header}"/>
            </f:facet>
           
            <h:outputText value="#{msgs.namePromt}"></h:outputText>
            <h:inputText id="name"  required="true" value="#{user.name}">
            <f:validateLength minimum="2" maximum="10"></f:validateLength>
            </h:inputText>
            <h:message for="name" errorClass="errors"/>
           
           
            <h:outputText value="#{msgs.passwordPromt}"></h:outputText>
           
            <h:inputSecret id="password" value="#{user.password}" required="true" redisplay="true">
            <f:validateLength minimum="2"></f:validateLength>
            </h:inputSecret>
            <h:message for="password"/>
           
           
                  <f:facet name="footer" >
            <h:outputText value="#{msgs.footer}"/>
            </f:facet>
            </h:panelGrid>          
                <h:commandButton value="#{msgs.submitPromt}" action="#{user.verify}"/>
                <h:commandButton value="#{msgs.resetPromt}" type="reset"/>
            </h:form>
        </f:view>
    </body>
    </html>



    welcome.jsp


    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK"/>
    <title></title>
    </head>
    <body>
        <f:view>
            <h:outputText value="#{user.name}"/>  is a good boy!
            <h3>welcome JavaServer Faces</h3>
        </f:view>
    </body>

    </html>
         編輯WEB-INF/lib下的faces-config.xml

    struts-config.xml

    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
    <navigation-rule>
            <from-view-id>/login.jsp</from-view-id>
            <navigation-case>
                <from-outcome>success</from-outcome>
                <to-view-id>/welcome.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>failure</from-outcome>
                <to-view-id>/login.jsp</to-view-id>
            </navigation-case>
    </navigation-rule>


    <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>com.jsf.UserBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    </faces-config>


           最后是資源文件

    # --login.jsp--
    header=Welcom
    namePromt=Name:
    passwordPromt=Password:
    amountPromt=Amount:
    datePromt=Date:
    submitPromt=Submit
    resetPromt=Reset
    footer=Thank you!


    3.測(cè)試
    在test工程中選擇tomcat project->Update context definition
    然后運(yùn)行Tomcat
    http://127.0.0.1:8080/jsfTest/login.jsf

    posted on 2005-12-10 12:05 all gone 閱讀(17651) 評(píng)論(11)  編輯  收藏 所屬分類: Java

    評(píng)論

    # re: Eclipse下JSF入門 2007-01-11 10:10 小鳥[匿名]

    login.jsp
    怎么兩個(gè)
    <%@ page contentType="text/html; charset=GBK" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>


    MessageResources.prxxxxx 放在哪進(jìn)里???


    俺試了,,漏洞百出,,,

    不好意思,俺今天才接觸jsf.....  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2007-01-12 18:28 all gone[匿名]

    # --login.jsp-- 是在資源文件里的
    表示這是在login.jsp中用到的

    肯定只會(huì)有一個(gè)login.jsp  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2007-08-10 08:31 few

    https://sourceforge.jp/projects/amateras/files
    -----------
    樓主給個(gè)日文的鏈接,是在賣弄嗎?  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2007-08-31 00:43 hello

    樓上的不懂不要亂說。

    只有日文的。  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門[未登錄] 2007-09-14 15:39 kevin

    呵呵,笑死了。日文連接。你不還給個(gè)中文的,我也沒看懂啊。下來試試的。  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門[未登錄] 2007-09-14 15:42 kevin

    myeclipse里面都有,有區(qū)別嗎?  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2008-04-10 14:32 鵝鵝鵝

    小破程序員還挺愛國(guó),還抗日
    這哥們應(yīng)該早生70年  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2008-10-29 18:56 sfd

    就沒有自動(dòng)寫發(fā)faces-config.xml文件嘛  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2009-01-13 11:05 飛雪、

    日文的里面點(diǎn)美國(guó)國(guó)旗應(yīng)該就都是英文了吧,除了廣告圖片!  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門[未登錄] 2009-03-17 20:50 躺著讀書

    我也愛日本 咋了

    但是我還是給一個(gè)elipse for j2ee的官方版本的jsf環(huán)境設(shè)置教程。
    http://www.eclipse.org/webtools/jsf/docs/tutorial/JSFTools_1_0_tutorial.html

    eclipse官方是內(nèi)置了對(duì)于jsf的支持的,只是默認(rèn)這個(gè)功能沒有打開。需要配置。新建項(xiàng)目后轉(zhuǎn)到內(nèi)置web程序的視圖。比netbeans 好多了。  回復(fù)  更多評(píng)論   

    # re: Eclipse下JSF入門 2009-07-27 20:51 fuck japan

    fuck japan  回復(fù)  更多評(píng)論   

    主站蜘蛛池模板: 亚洲爆乳无码精品AAA片蜜桃| 亚洲国产情侣一区二区三区| 亚洲情A成黄在线观看动漫软件| 久久国产免费观看精品| 免费在线人人电影网| 在线免费视频你懂的| 亚洲女同成人AⅤ人片在线观看| 亚洲一区二区三区高清在线观看| 久久午夜免费视频| 亚洲国产精品午夜电影| 亚洲电影免费观看| 亚洲另类精品xxxx人妖| 手机在线看永久av片免费| 亚洲人配人种jizz| 国产免费久久久久久无码| 在线观看亚洲天天一三视| 欧美在线看片A免费观看| 亚洲毛片基地日韩毛片基地| 含羞草国产亚洲精品岁国产精品| 日韩免费的视频在线观看香蕉 | 一级毛片免费视频| 全免费a级毛片免费看无码| 亚洲中文字幕无码亚洲成A人片| 四虎成人免费影院网址| 污污免费在线观看| 日本亚洲视频在线| 免费v片在线观看视频网站| 国产亚洲日韩在线三区| 99爱在线精品视频免费观看9| 久久亚洲精品专区蓝色区| 亚洲高清偷拍一区二区三区| 成人黄网站片免费视频| 国产精品亚洲精品观看不卡| 在线观看免费a∨网站| 一级看片免费视频| 免费无码A片一区二三区| 日韩精品无码永久免费网站| 亚洲∧v久久久无码精品| 免费看内射乌克兰女| 亚洲日韩精品一区二区三区无码| 男人免费视频一区二区在线观看|