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

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

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

    隨筆-124  評論-49  文章-56  trackbacks-0
      2010年11月22日
         摘要: JSF學習筆記   JSF事件驅動型的MVC框架,與流行的struts比較學習,易于理解。jsf component event事件是指從瀏覽器由用戶操作觸發的事件,Struts application event 是用Action來接受瀏覽器表單提交的事件,一個表單只能對應一個事件,application event和component event相比是一種粗粒度的事件。優點:事件...  閱讀全文
    posted @ 2011-05-30 21:48 junly 閱讀(1275) | 評論 (2)編輯 收藏
    Struts2 的UITag原理:
    Struts2 UITag分三部份組成,一部份用于定義Tag的內容與邏輯的UIBean,一部份用于定義JSP Tag,也就是平時我們定義的那種,最后就是Template,它存放在你的theme目錄之下,是一個FreeMarker模板文件。

    我現在輯寫一份MMTag,它主要是用于輸出帶鏈接的文字,比如像這樣:
    <cur:mm message="'I am a boy.'" />
    就會輸出:
    <a href="http://m.tkk7.com/natlive">I am boy.</a>

    我們先寫UIBean部份:我們把它定義為MM,它繼承于 org.apache.struts2.components.UIBean:

    package limitstudy.corestruts2.tag;

    import org.apache.struts2.components.UIBean;
    import org.apache.struts2.views.annotations.StrutsTag;
    import org.apache.struts2.views.annotations.StrutsTagAttribute;
    import com.opensymphony.xwork2.util.ValueStack;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    @StrutsTag(name="mm", tldTagClass="limitstudy.corestruts2.tag.MMTag", description="MM")
    public class MM extends UIBean {
        private String message;

        public MM(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
            super(stack, request, response);
        }

        @Override
        protected String getDefaultTemplate() {
            return "mm";
        }

        @StrutsTagAttribute(description="set message", type="String")
        public void setMessage(String message) {
            this.message = message;
        }

        @Override
        protected void evaluateExtraParams() {
            super.evaluateExtraParams();

            if (null != message) {
                addParameter("message", findString(message));
            }
        }
    }


    * strutsTag注解指明了該UIBean的名字 和Tag類的類名。
    * getDefaultTemplate()方法用于返回模板的名 字,Struts2會自動在后面加入.ftl擴展名以找到特定的模板文件。
    * setXXX,設置UIBean的屬性,一般Tag中有幾個這樣的屬性,這里就有幾個。@StrutsTagAttribute(description="set message", type="String") 注解,說明該屬性是字符串(也可以是其它),這一步很重要。
    * 覆寫evaluateExtraParams() 方法,在UIBean初始化后會調用這個方法來初始化設定參數,如addParameter方法,會在freemarker里的parameters里加 入一個key value。這里要注意findString,還有相關的findxxxx方法,它們是已經封裝好了的解釋ognl語法的工具,具體是怎么樣的,大家可以 查看一下UIBean的api doc。

    然后是Tag部份:

    package limitstudy.corestruts2.tag;

    import org.apache.struts2.views.jsp.ui.AbstractUITag;
    import org.apache.struts2.components.Component;
    import com.opensymphony.xwork2.util.ValueStack;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    public class MMTag extends AbstractUITag {
        private String message;

        @Override
        public Component getBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
            return new MM(stack, request, response);
        }

        @Override
        protected void populateParams() {
            super.populateParams();

            MM mm = (MM)component;
            mm.setMessage(message);
        }

        public void setMessage(String message) {
            this.message = message;
        }
    }


    * getBean()返回該Tag中的UIBean。
    * populateParams()初始化參數,一般用來初始化UIBean(Component)。
    * setXXXX設置屬性,和jsp tag是一樣的。

    在/WEB-INF/tlds/下建立current.tld文件(文名隨你喜歡):

    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
        <description>test</description>
        <tlib-version>2.0</tlib-version>
        <short-name>cur</short-name>
        <uri>/cur</uri>

        <tag>
            <name>mm</name>
            <tag-class>limitstudy.corestruts2.tag.MMTag</tag-class>
            <body-content>JSP</body-content>
            <attribute>
                <name>message</name>
                <required>true</required>
            </attribute>
        </tag>
    </taglib>


    在源代碼目錄中建立template/simple目錄(這個目錄名和你的theme有關),然后在里面建一個 mm.ftl文件:

    <href="http://www.yinsha.com">${parameters.message?html}</a>


    建一個action測試一下,視圖文件:

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <%@ taglib prefix="cur" uri="/cur" %>
    <html>
    <head>
        <title><s:property value="message" /></title>
    </head>
    <body>
    <cur:mm message="haoahahhahaha" />
    </body>
    </html>


    完。

    PS: 寫得有些粗鄙,所以,如有問題的,可以留言。

     

     

     

    http://devilkirin.javaeye.com/blog/427395

    http://xiaojianhx.javaeye.com/blog/482888
    posted @ 2011-05-30 21:43 junly 閱讀(1133) | 評論 (1)編輯 收藏

    Page


    The following is register.jsp, which takes required information from user regarding registration. For this example, we focus only on validation of username and not the actual registration process.

    The most important thing is to know how to access JSF component from JQuery. The id given to inputText is consisting of formid:componentid. So in this example the id given to textbox is  registerform:username. But the presence of : (colon) causes problem to JQuery. So, we need to escape : (colon) using two \\ characters before colon - registerform\\:username.

    //register.jsp
    <%@page contentType="text/html" %>de">

    <%@page contentType=
    "text/html" %>
    <!DOCTYPE HTML PUBLIC 
    "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        
    <head>
            
    <script language="javascript" src="jquery-1.4.2.js"></script>
            
    <script language="javascript">
                
    function checkUsername(){
                    $.get( 
    "checkusername.jsp",{username : $("#registerform\\:username").val()},updateUsername);
                }
                
    function updateUsername(response)
                {
                    
    if (response) {
                        $(
    "#usernameresult").text(response);  // update SPAN item with result
                }
            
    </script>
            
    <title>Registration</title>
        
    </head>
        
    <body>
            
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
            
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
            
    <f:view>
               
    <h2>Registration </h2>
               
    <h:form  id="registerform">
               
    <table>
                        
    <tr>
                            
    <td>Username : </td>
                            
    <td><h:inputText id="username" value="#{userBean.username}"  required="true" onblur="checkUsername()" />
                                
    <h:message for="username" />
                                
    <span id="usernameresult" />
                        
    </tr>
                        
    <tr>
                            
    <td>Password : </td>
                            
    <td><h:inputSecret id="password" value="#{userBean.password}"  required="true" /> <h:message for="password" /> </td>
                        
    </tr>
                        
    <tr>
                            
    <td>Re-enter Password : </td>
                            
    <td><h:inputSecret id="confirmPwd" value="#{userBean.confirmPwd}"  required="true" /> <h:message for="confirmPwd" /> </td>
                        
    </tr>
                        
    <tr>
                            
    <td>Email Address  : </td>
                            
    <td><h:inputText id="email" value="#{userBean.email}" required="true" onblur="checkEmail()"  /> <h:message for="email" /> </td>
                                
    <span id="emailresult" />
                        
    </tr>
                   
    </table>
                                    
                  
    <p/>
                  
    <h:commandButton actionListener="#{userBean.register}" value="Register" />
                  
    <p/>
                  
    <h3><h:outputText value="#{userBean.message}" escape="false"  /> </h3>
                  
    <p/>
               
    </h:form>
            
    </f:view>
        
    </body>
    </html>lt;/f:view>
        
    </body>
    </html>

    Bean


    The above JSF Form uses userBean, which is the name given to beans.UserBean class. The class and its entries in faces-config.xml file are given below.
    UserBean is the managed bean that stores data coming from JSF form. It contains an action listener - register(), which is supposed to process the data to complete registration process. We don't deal with it as our focus is only on validating username.
    //UserBean.java
    package beans;

    public class UserBean {
        
    private String username, password, email,confirmPwd, message;

        
    public UserBean() {
        }

        
    public String getPassword() {
            
    return password;
        }

        
    public void setPassword(String password) {
            
    this.password = password;
        }

        
    public String getUsername() {
            
    return username;
        }

        
    public void setUsername(String username) {
            
    this.username = username;
        }

        
    public String getConfirmPwd() {
            
    return confirmPwd;
        }

        
    public void setConfirmPwd(String confirmPwd) {
            
    this.confirmPwd = confirmPwd;
        }

        
    public String getEmail() {
            
    return email;
        }

        
    public void setEmail(String email) {
            
    this.email = email;
        }

        
    public String getMessage() {
            
    return message;
        }

        
    public void setMessage(String message) {
            
    this.message = message;
        }

        
    public void  register(ActionEvent evt) {
           
    if (! password.equals(confirmPwd))
           {
                 message 
    = "Password do not match!";
                 
    return;
           }
           
    // do registration
        } // register
    }

    xml


    The following entry is required in faces-config.xml for UserBean managed bean.
    <!-- faces-config.xml -->
    <managed-bean>
            
    <managed-bean-name>userBean</managed-bean-name>
            
    <managed-bean-class>beans.UserBean</managed-bean-class>
            
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>  

    Check

    Now create a checkusername.jsp to check whether given username is valid. It sends a message if username is already exists otherwise it sends empty string (nothing).
    <%@ page import="java.sql.*"  contentType="text/plain"%>
    <%
     String username 
    = request.getParameter("username");  // sent from client
     
    // connect to oracle using thin driver
     Class.forName("oracle.jdbc.driver.OracleDriver");
     Connection con 
    = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","youruser","yourpassword");
     PreparedStatement ps 
    = con.prepareStatement("select username from users where username = ?");
     ps.setString(
    1,username);
     ResultSet  rs 
    = ps.executeQuery();
     
    if ( rs.next()) { // found username
        out.println("Username is already present!");  // send this to client
     }
     rs.close();
     ps.close();
     con.close();
    %>

    Deploy and Test

    Now deploy the web application and run register.jsp. If you enter a username that is already present in USERS table then we get message - Username is already present - in SPAN item on the right of username field. If username is unique then SPAN item is set to empty string ( as JSP returns nothing).

    from:http://www.srikanthtechnologies.com/blog/java/jquerywithjsf.aspx
    posted @ 2011-05-30 21:38 junly 閱讀(791) | 評論 (0)編輯 收藏

    Java 7已經完成的7大新功能:
          1 對集合類的語言支持;
          2 自動資源管理;
          3 改進的通用實例創建類型推斷;
          4 數字字面量下劃線支持;
          5 switch中使用string;
          6 二進制字面量;
          7 簡化可變參數方法調用。

          下面我們來仔細看一下這7大新功能:
          1 對集合類的語言支持
          Java將包含對創建集合類的第一類語言支持。這意味著集合類的創建可以像Ruby和Perl那樣了。
          原本需要這樣:
             List<String> list = new ArrayList<String>();
             list.add("item");
             String item = list.get(0);
      
             Set<String> set = new HashSet<String>();
             set.add("item");
             Map<String, Integer> map = new HashMap<String, Integer>();
             map.put("key", 1);
             int value = map.get("key");

          現在你可以這樣:
             List<String> list = ["item"];
             String item = list[0];
            
             Set<String> set = {"item"};
            
             Map<String, Integer> map = {"key" : 1};
             int value = map["key"];

          這些集合是不可變的。

      
          2 自動資源管理
          Java中某些資源是需要手動關閉的,如InputStream,Writes,Sockets,Sql classes等。這個新的語言特性允許try語句本身申請更多的資源,
       這些資源作用于try代碼塊,并自動關閉。
          這個:
             BufferedReader br = new BufferedReader(new FileReader(path));
             try {
             return br.readLine();
                   } finally {
                       br.close();
             }

          變成了這個:
              try (BufferedReader br = new BufferedReader(new FileReader(path)) {
                 return br.readLine();
              }
       
          你可以定義關閉多個資源:
             try (
                 InputStream in = new FileInputStream(src);
                 OutputStream out = new FileOutputStream(dest))
             {
             // code
             }
          為了支持這個行為,所有可關閉的類將被修改為可以實現一個Closable(可關閉的)接口。
      

          3 增強的對通用實例創建(diamond)的類型推斷
          類型推斷是一個特殊的煩惱,下面的代碼:
             Map<String, List<String>> anagrams = new HashMap<String, List<String>>();

          通過類型推斷后變成:
             Map<String, List<String>> anagrams = new HashMap<>();
          這個<>被叫做diamond(鉆石)運算符,這個運算符從引用的聲明中推斷類型。

      
          4 數字字面量下劃線支持
          很長的數字可讀性不好,在Java 7中可以使用下劃線分隔長int以及long了,如:
             int one_million = 1_000_000;
       運算時先去除下劃線,如:1_1 * 10 = 110,120 – 1_0 = 110
      

          5 switch中使用string
          以前你在switch中只能使用number或enum。現在你可以使用string了:
             String s = ...
             switch(s) {
             case "quux":
                  processQuux(s);
         // fall-through
             case "foo":
       case "bar":
                  processFooOrBar(s);
         break;
             case "baz":
            processBaz(s);
                  // fall-through
       default:
                  processDefault(s);
                break;
      }

      
          6 二進制字面量
          由于繼承C語言,Java代碼在傳統上迫使程序員只能使用十進制,八進制或十六進制來表示數(numbers)。
          由于很少的域是以bit導向的,這種限制可能導致錯誤。你現在可以使用0b前綴創建二進制字面量:
             int binary = 0b1001_1001;
       現在,你可以使用二進制字面量這種表示方式,并且使用非常簡短的代碼,可將二進制字符轉換為數據類型,如在byte或short。
       byte aByte = (byte)0b001;   
       short aShort = (short)0b010;   

      
          7 簡化的可變參數調用
          當程序員試圖使用一個不可具體化的可變參數并調用一個*varargs* (可變)方法時,編輯器會生成一個“非安全操作”的警告。
       JDK 7將警告從call轉移到了方法聲明(methord declaration)的過程中。這樣API設計者就可以使用vararg,因為警告的數量大大減少了。

    posted @ 2011-03-18 15:21 junly 閱讀(16865) | 評論 (9)編輯 收藏

     
    A:
    <s:a href=""></s:a>-----超鏈接,類似于html里的<a></a>
    <s:action name=""></s:action>-----執行一個view里面的一個action
    <s:actionerror/>-----如果action的errors有值那么顯示出來
    <s:actionmessage/>-----如果action的message有值那么顯示出來
    <s:append var="newMerList">-----添加一個值到list,類似于list.add();
     <s:param value="merList1"></s:param>   
     <s:param value="merList2"></s:param>   
    </s:append>

    <s:autocompleter></s:autocompleter>-----自動完成<s:combobox>標簽的內容,這個是ajax

    B:
    <s:bean name=""></s:bean>-----類似于struts1.x中的,JavaBean的值

    C:
    <s:checkbox></s:checkbox>-----復選框
    <s:checkboxlist list=""></s:checkboxlist>-----多選框
    <s:combobox list=""></s:combobox>-----下拉框
    <s:component></s:component>-----圖像符號

    D:
    <s:date name="time" format="yyyy/MM/dd"/>-----獲取日期格式
    <s:datetimepicker></s:datetimepicker>-----日期輸入框
    <s:debug></s:debug>-----顯示錯誤信息
    <s:div></s:div>-----表示一個塊,類似于html的<div></div>
    <s:doubleselect list="#appVar3" listKey="id" listValue="name" name="" doubleName="chinagra.chinagraCategory.id" -----雙下拉框
    doubleId="mid" doubleList="#appVar4.get(top.id)" doubleListKey="id" doubleListValue="title" theme="simple"/>
    List<Category> categories = chinagraService.searchProblemCategories();;
    Map<Long, List<ChinagraCategory>> chinagraCategories = new HashMap<Long, List<ChinagraCategory>>();
    for(Category category : categories) {
     chinagraCategories.put(category.getId(), chinagraCategoryService.queryByType(category.getId().toString()));
    }

    E:
    <s:if test=""></s:if>
    <s:elseif test=""></s:elseif>
    <s:else></s:else>-----這3個標簽一起使用,表示條件判斷

    F:
    <s:fielderror></s:fielderror>-----顯示文件錯誤信息
    <s:file></s:file>-----文件上傳
    <s:form action=""></s:form>-----獲取相應form的值

    G:
    <s:generator separator="'aaa,bbb,ccc,ddd'" val=",">
     <s:iterator>   
      <s:property/>   
        </s:iterator>
    </s:generator>----和<s:iterator>標簽一起使用


    H:
    <s:head/>-----在<head></head>里使用,表示頭文件結束
    <s:hidden name="user.name" value="junly"/></s:hidden>-----隱藏值

    I:
    <s:i18n name=""></s:i18n>-----加載資源包到值堆棧
    <s:include value=""></s:include>-----包含一個輸出,servlet或jsp頁面
    <s:inputtransferselect list=""></s:inputtransferselect>-----獲取form的一個輸入
    <s:iterator value="userlist" var="user" status="s">
     <s:if test="#s.index == 0">
      <s:property value="name"/>
     </s:if>
     <s:property value="#s.even"/>
        <s:property value="#s.odd"/>  
     <s:property value="#s.first"/> 
     <s:property value="#s.last"/> 
     <s:property value="#s.count"/> 
    </s:iterator>-----用于遍歷集合
    <s:if test="#list.size > 0 "></s:if>-----判斷 ActionContext.getContext().put("list", lists);
    <s:elseif test="list.size > 0 "></s:elseif>
    <s:else></s:else>
    <s:if test="searchCondition.filter!=null">

    L:
    <s:label></s:label>-----只讀的標簽

    M:
    <s:merge></s:merge>-----合并遍歷集合出來的值

    O:
    <s:optgroup></s:optgroup>-----獲取標簽組
    <s:optiontransferselect doubleList="" list="" doubleName=""></s:optiontransferselect>-----左右選擇框

    P:
    <s:param name="pageSize" value="pageSize"/></s:param>-----為其他標簽提供參數
    <s:password></s:password>-----密碼輸入框
    <s:property value="user.name" />-----得到'value'的屬性
    <s:push value=""></s:push>-----value的值push到棧中,從而使property標簽的能夠獲取value的屬性

    R:

    <s:radio name="type" list="#{0:'拍賣會',1:'展會'}" value="0"></s:radio>-----單選按鈕
    <s:reset></s:reset>-----重置按鈕

    S:
    <s:select list=""></s:select>-----單選框
    <s:set name=""></s:set>-----賦予變量一個特定范圍內的值
    <s:sort comparator=""></s:sort>-----通過屬性給list分類
    <s:submit></s:submit>-----提交按鈕
    <s:subset source="#subList" start="1" count="2">-----為遍歷集合輸出子集 
     <s:iterator>   
      <s:property/> 
     </s:iterator>   
    </s:subset>


    T:
    <s:tabbedPanel id=""></s:tabbedPanel>-----表格框
    <s:table></s:table>-----表格
    <s:text name="error"/></s:text>-----I18n文本信息
    <s:textarea></s:textarea>-----文本域輸入框
    <s:textfield></s:textfield>-----文本輸入框
    <s:token></s:token>-----攔截器
    <s:tree></s:tree>-----樹
    <s:treenode label=""></s:treenode>-----樹的結構

    U:
    <s:updownselect list=""></s:updownselect>-----多選擇框
    <s:url value="/academy/get-detail.action?academyInfo.id=${id}"></s:url>-----創建url
    <s:url action="search-big.action" escapeAmp="false" namespace="/problem">            
    <s:param name="name" value="%{'all'}"/>
    <s:param name="id" value="0"/>      
    <s:param name="sex" value="user.sex"/>                                    
    </s:url>

     

     

    JSTL語法及參數   
    JSTL包含以下的標簽:   
    常用的標簽:如<c:out>、<c:remove>、<c:catch>、<c:set>等   
    條件標簽:如<c:if><c:when>、<c:choose>、<c:otherwise>等   
    URL標簽:如<c:import>、<c:redirect>和<c:url>等   
    XML標簽:如<xml:out>等   
    國際化輸出標簽:如<fmt:timeZone>等   
    SQL標簽:如<sql:query>、<sql:update>、<sql:transaction>等   
     
    一般用途的標簽:   
    1.<c:out>   
    沒有Body時的語法   
    <c:out value=”value” [escapeXml=”{true|false}”] [default=”defaultValue”]/>   
    有Body時的語法   
    <c:out value=”value” [escapeXml=”{true|false}”]>   
    這里是Body部分   
    </c:out>   
     
    名字 類型 描述   
    value Object 將要輸出的表達式   
    escapeXml boolean 確定以下字符:<,>,&,’,”在字符串中是否被除數,默認為true   
    default Object 如果vaule計算后的結果是null,那么輸出這個默認值   

    2.<c:set>   
    這個標簽用于在某個范圍(page、request、session、application等)中使用某個名字設定特定的值,或者設定某個已經存在的javabean對象的屬性。他類似于<%request.setAttrbute(“name”,”value”);%>   
    語法1:使用value屬性設定一個特定范圍中的屬性。   
    <c:set value=”value” var=”varName” [scope=”{page|request|session|application}”]/>   
    語法2:使用value屬性設定一個特定范圍中的屬性,并帶有一個Body。   
    <c:set var=”varName” [scope=”{page|request|session|application}”]>   
    Body部分   
    </c:set>   
    語法3:設置某個特定對象的一個屬性。   
    <c:set value=”value” target=”target” property=”propertyName”/>   
    語法4:設置某個特定對象的一個屬性,并帶有一個Body。   
    <c:set target=”target” property=”propertyName”>   
    Body部分   
    </c:set>   
     
    名字 類型 描述   
    value Object 將要計算的表到式。   
    var String 用于表示value 值的屬性,如果要在其他標簽中使用,就是通過這 個var指定的值來進行的。它相當于在標簽定義了一個變量,并且這個變量只能在標簽中的一個。   
    scope String var的有效范圍,可以是page|request|session|application中的一個   
    target String 將要設置屬性的對象,它必須是javabean或則java.util.Map對象   
    property Object 待設定的Target對象中的屬性名字,比如在javabean中有個name屬性,提供了setUserId方法,那么這里填userId。    
     
    3.<c:remove>   
    <c:remove var=”varName” [scope=”{page|request|session|application}”]/>    
     
    4.<c:catch>   
    這個標簽相當于捕獲在它里邊的標簽拋出的異常對象   
    <c:catch [var=”varName”]> //var是異常的名字   
    內容   
    </c:catch>    
     
    條件標簽   
    1. <c:if>   
    語法1:無Body情況   
    <c:if test=”testCondition” var=”varName” [scope=”page|request|session|application”]/>   
    語法2:有Body的情況   
    <c:if test=”testCondition” var=”varName” [scope=”page|request|session|application”]>   
    Body內容   
    </c:if>   
     
    名字 類型 描述   
    test Boolean 表達式的條件,相當于if()中的條件判斷語句。   
    var String 表示這個語句的名字。   
    scope String var這個變量的作用范圍。    
     
    2.<c:choose>   
    語法:<c:choose>   
    Body內容(<c:when>和<c:otherwise>子標簽)   
    </c:choose>   
    注意:它的Body只能由以下元素組成:   
    1) 空格   
    2) 0或多個<c:when>子標簽,<c:when>必須在<c:otherwise>標簽之前出現.   
    3) 0個或多個<c:otherwise>子標簽。   
    <c:choose>
       <c:when test="${param.age>70}">
       歡迎老年人
       </c:when>
       <c:when test="${param.age<70 and param.age>35}">
       歡迎中年人
       </c:when>
       <c:otherwise>
       您的年齡有誤!
       </c:otherwise>
    </c:choose>
     
    3.<c:when>   
    代表的是<c:choose>的一個條件分支,只能在<c:choose>中使用   
    語法:<c:when test=”testCondition”> //test是boolean類型,用于判斷條件真假   
    Body語句   
    </c:when>    
     
    4.<c:otherwise>   
    代表的是<c:choose>中的最后選擇。必須在最后出現   
    <c:otherwise>   
    內容   
    </c:otherwise>    
     
    迭代標簽   
    1.<c:forEach>   
    語法1:在Collection中迭代   
    <c:forEach[var=”varName”] items=”collection” [varStatus=”varStatusName”]   
    [begin=”begin”] [end=”end”] [step=”step”]   
    Body內容   
    </c:foeEach>   
     
    語法2:迭代固定的次數.   
    <c:forEach [var=”varName”] [varStatus=”varStatusName”]   
    [begin=”begin”] [end=”end”] [step=”step”]   
    Body內容   
    </c:foeEach>   
     
    名字 類型 描述   
    var String 迭代的參數,它是標簽參數,在其他標簽中通過它來引用這個標簽中的內容。   
    Items Collection、ArrayList、 要迭代的items集合.   
    Iterator、Map、String、   
    Eunmeration等   
    VarStatus String 表示迭代的狀態,可以訪問迭代自身的信息   
    Begin int 表示開始迭代的位置。   
    End int 表示結束迭代的位置。   
    Step int 表示迭代移動的步長,默認為1。    
     
    URL相關的標簽   
    1.<c:import>   
    語法1:資源的內容使用String對象向外暴露   
    <c:import url=”url” [context=”context”]   
    [var=”varName”] [scope=”{page|request|session|application}”] [charEncoding=”charEncoding”]>   
    內容   
    </c:import>   
     
    語法2:資源的內容使用Reader對象向外暴露。   
    <c:import url=”url” [context=”context”]   
    varReader=”varReaderName” [charEncoding=”charEncoding”]>   
    內容   
    </c:import>   
    名字 類型 描述   
    url String 待導入資源的URL,可以是相對路徑和絕對路徑,并且可以導入其他主機資源   
    context String 當使用相對路徑訪問外部context資源時,context指定了這個資源的名字。   
    var String 參數的名字。   
    scope String var參數的作用范圍。   
    cahrEncoding String 輸入資源的字符編碼。   
    varReader String 這個參數的類型是Reader,用于讀取資源。    
     
    2.<c:redirct>   
    語法1:沒有Body的情況.   
    <c:redirect url=”value” [context=”context”]/>   
    語法2:有Body情況下,在Body中指定查詢的參數   
    <c:redirect url=”value” [context=”context”]>   
    <c:param name=”name” value=”value”/>   
    </c:redirect>    
     
    3.<c:url>   
    語法1:沒有Body   
    <c:url value=”value” [context=”context”] [var=”varName”] [scope=”{page|request|session+application}”]/>   
    語法2:有Body   
    <c:url value=”value” [context=”context”] [var=”varName”] [scope=”{page|request|session+application}”]>   
    <c:param name=”name” value=”value”/>   
    </c:url>   
     
    名字 類型 描述   
    value String URL值   
    context String 當使用相對路徑訪問外部context資源時,context指定了這個資源的名字   
    var String 標識這個URL標量。   
    Scope String 變量作用范圍。    
     
    SQL相關的標簽   
    1.<sql:setDataSource>   
    2.<sql:query>   
    3.<sql:update>   
    4.<transaction>   
    5.<param>

    posted @ 2010-11-22 10:41 junly 閱讀(417) | 評論 (0)編輯 收藏
    主站蜘蛛池模板: 久久一区二区免费播放| 男女猛烈无遮掩视频免费软件 | 免费A级毛片无码视频| 久久久久亚洲av无码专区导航| 国产精品视频免费观看| 亚洲日本中文字幕天天更新| mm1313亚洲精品无码又大又粗| 免费无码黄网站在线看| 国产色在线|亚洲| 亚洲第一区精品日韩在线播放| 久久久久久免费一区二区三区 | 精品亚洲AV无码一区二区三区| 国产在线观看www鲁啊鲁免费| 久久久久久久国产免费看| 亚洲国产精品综合一区在线| 全黄a免费一级毛片人人爱| 久久中文字幕免费视频| 粉色视频免费入口| 亚洲国产电影在线观看| 亚洲日韩人妻第一页| 毛片免费全部播放无码| a一级爱做片免费| 亚洲日本在线电影| 亚洲va久久久噜噜噜久久男同 | 亚洲电影中文字幕| www.亚洲精品| 成年轻人网站色免费看| 久草免费福利资源站| 全黄A免费一级毛片| 亚洲国产91在线| 亚洲精品高清久久| 亚洲精品成人网久久久久久| 97无码免费人妻超级碰碰碰碰 | 亚洲乱码在线播放| 日韩亚洲人成在线综合日本| 又粗又大又硬又爽的免费视频| 两性刺激生活片免费视频| 成人免费区一区二区三区| 思思久久99热免费精品6| 亚洲人成色777777精品| 亚洲性一级理论片在线观看|