panda

          IT高薪不是夢(mèng)!!

          統(tǒng)計(jì)

          留言簿

          閱讀排行榜

          評(píng)論排行榜

          2009年7月16日 #

          文件上傳(FileUpload)

          1.使用JAR
          ??????jsp文件上傳主要使用了兩個(gè)jar包,commons-fileupload-1.2.1.jar和commons-io-1.4.jar
          2.代碼實(shí)現(xiàn)
          ???? public class UploadServlet extends HttpServlet {

          ?/**
          ? *
          ? */
          ?private static final long serialVersionUID = 1L;

          ?private ServletContext sc;

          ?private String savePath;

          ?@Override
          ?protected void doGet(HttpServletRequest request,
          ???HttpServletResponse response) throws ServletException, IOException {
          ??doPost(request, response);
          ?}

          ?@Override
          ?protected void doPost(HttpServletRequest request,
          ???HttpServletResponse response) throws ServletException, IOException {

          ??System.out.println("請(qǐng)求進(jìn)來(lái)了..........");

          ??// 設(shè)置請(qǐng)求的編碼
          ??request.setCharacterEncoding("UTF-8");

          ??DiskFileItemFactory factory = new DiskFileItemFactory();//創(chuàng)建一個(gè)磁盤(pán)文件工廠
          ??ServletFileUpload upload = new ServletFileUpload(factory);

          ??try {
          ???List items = upload.parseRequest(request);
          ???Iterator it = items.iterator();
          ???while (it.hasNext()) {
          ????FileItem item = (FileItem) it.next();

          ????if (item.isFormField()) {
          ?????System.out.println("表單的參數(shù)名稱:" + item.getFieldName()
          ???????+ ",對(duì)應(yīng)的參數(shù)值:" + item.getString("UTF-8"));
          ????} else {
          ?????// 獲取文件擴(kuò)展名
          ?????String strtype = item.getName().substring(
          ???????item.getName().length() - 3,
          ???????item.getName().length());
          ?????strtype = strtype.toLowerCase();

          ?????if (strtype == "jpg" || strtype == "gif"
          ???????|| strtype == "txt") {
          ??????if (item.getName() != null
          ????????&& !item.getName().equals("")) {
          ???????System.out.println("上傳文件的大小:" + item.getSize());
          ???????System.out.println("上傳文件的類型:"
          ?????????+ item.getContentType());
          ???????System.out.println("上傳文件的名稱:" + item.getName());

          ???????System.out.println("文件的擴(kuò)展名" + strtype);
          ???????File tempFile = new File(item.getName());
          ???????File file = new File(
          ?????????sc.getRealPath("/") + savePath, tempFile
          ???????????.getName());
          ???????item.write(file);

          ???????request.setAttribute("upload.message", "上傳文件成功!");

          ??????} else {
          ???????request.setAttribute("upload.message",
          ?????????"沒(méi)有選擇上傳文件獲取格式不支持");
          ??????}
          ?????} else {
          ??????request.setAttribute("upload.message", "上傳文件格式不支持");
          ?????}
          ????}
          ???}
          ??} catch (Exception e) {
          ???e.printStackTrace();
          ???request.setAttribute("upload.message", "上傳文件不成功!");
          ??}
          ??// 轉(zhuǎn)發(fā)
          ??request.getRequestDispatcher("/uploadResult.jsp").forward(request,
          ????response);
          ?}

          ?@Override
          ?public void init(ServletConfig config) throws ServletException {

          ??savePath = config.getInitParameter("savePath");
          ??sc = config.getServletContext();
          ?}

          posted @ 2009-11-08 16:30 IT追求者 閱讀(172) | 評(píng)論 (0)編輯 收藏

          Hibernate的多對(duì)一關(guān)聯(lián)映射

          1.關(guān)聯(lián)映射的本質(zhì):就是將關(guān)聯(lián)關(guān)系映射到數(shù)據(jù)庫(kù)中,關(guān)聯(lián)關(guān)系指對(duì)象模型中的一個(gè)或多個(gè)引用.

          2.下面列舉多對(duì)一的示例:用戶和組(多個(gè)用戶屬于一個(gè)組)多對(duì)一關(guān)聯(lián)映射是最常用的一種關(guān)聯(lián)映射

          ?? *User 類
          ???package com.lzy
          ?? public class User{

          ?? private int id;
          ?? private String name;

          ? private Group group;//持有組的引用
          ???
          ?? public User(){};

          ?? //省略set,get方法
          ?}


          ? *Group類
          ?package com.lzy
          ?public class Group{
          ??
          ?? private int id;

          ?? private String name;
          ?? //省略get,set方法
          ?}

          3.對(duì)對(duì)象進(jìn)行關(guān)系映射,這也是Hibernate中比較難的一點(diǎn)。
          ? (1)User.hbm.xml
          ??????
          ??????<?xml version="1.0">
          ??????<!DOCTYPE?hibernate-mapping PUBLIC? "-//Hibernate/Hibernate Mapping DTD 3.0//EN" http://hibernate.sourceforge.net/hibernate-mapping-3.0
          .dtd">
          ?? ? <hibernate-mapping package="com.lzy">
          ?????????<class name="User" table="t_user">
          ???????????????<id name="id" column="id">
          ?????????????????????<genarator class="native"/>
          ????????????? </id>
          ????????????<property name="name" column="user_name" not-null="true"/>
          ????????????<many-to-one name="group" column="groupid"/>
          ??????? </calss>
          ???? </hibernate-mapping>


          ?? (2)Group.hbm.xml
          ?????????
          ??????<?xml version="1.0">
          ??????<!DOCTYPE?hibernate-mapping PUBLIC? "-//Hibernate/Hibernate Mapping DTD 3.0//EN" http://hibernate.sourceforge.net/hibernate-mapping-3.0
          .dtd">
          ?? ? <hibernate-mapping package="com.lzy">
          ?????????<class name="Group" table="t_group">
          ???????????????<id name="id" column="id">
          ?????????????????????<genarator class="native"/>
          ????????????? </id>
          ????????????<property name="name" column="group_name" not-null="true"/>
          ??????</class>
          ???</hibernate-mapping>

          4.測(cè)試

          public class? Test {
          ???
          ? public static void main(String args[]){

          ??????SessionFactory? sessionFactory=null;
          ????? Session? session=null;
          ????? Transaction?? transaction=null;
          ??????
          ??????sessionFactory = HibernateUtil.getSessionFactory();// 創(chuàng)建一個(gè)會(huì)話工廠
          ????? session = sessionFactory.openSession();// 創(chuàng)建一個(gè)會(huì)話實(shí)例
          ????? transaction = session.beginTransaction();// 申明一個(gè)事務(wù)

          ??User user= new User();
          ??Group?group = new Group();

          ??user.setName("龍一");

          ??group.setName("中南大學(xué)");
          ? user.setGroup(group);

          ??try {

          ???transaction.begin();
          ???session.save(user);
          ???transaction.commit();

          ??} catch (Exception e) {
          ???e.printStackTrace();
          ??}


          ?? }
          }

          posted @ 2009-10-12 17:56 IT追求者 閱讀(1425) | 評(píng)論 (2)編輯 收藏

          struts logic標(biāo)簽使用詳解

          Logic 比較標(biāo)簽(一)

          1.<logic:equal>

          判斷變量是否與指定的常量相等。例如:

          ???? <%

          ?????? pageContext.setAttribute("test",new Integer(100));

          ???? %>

          ???? <logic:equal value="100" name="test">

          ???????? test=100???? </logic:equal>

          2.<logic:greaterThan>

          判斷常量變量是否與指定的常量不相等。

          <html:link page="/greaterThan.jsp?test=123456">添加參數(shù)</html:link> //傳值

          <logic:greaterThan value="12347" parameter="test">

          ?????? true

          </logic:greaterThan>

          下面類似

          3.<logic:greaterEqual>

          判斷變量大小是否等于指定的常量。

          4.<logic:lessThan>

          判斷變量是否小于指定的常量。

          5.<logic:lessEqual>

          判斷變量是否小于等于指定的常量。

          Struts logic標(biāo)簽(二)

          循環(huán)遍歷標(biāo)簽<logic:iterate>

          該標(biāo)簽用于在頁(yè)面中創(chuàng)建一個(gè)循環(huán),以次來(lái)遍歷數(shù)組、Collection、Map這樣的對(duì)象。在Struts中經(jīng)常用到!

          例如:

          <%

          String []testArray={"str0","str1","str2","str3","str4","str5"};

          pageContext.setAttribute("test",testArray);

          %>

          <logic:iterate id="array" name="test">

          ??????? <bean:write name="array"/>

          </logic:iterate>

          首先定義了一個(gè)字符串?dāng)?shù)組,并為其初始化。接著,將該數(shù)組存入pageContext對(duì)象中,命名為test1。然后使用logic:iterate標(biāo)記的name屬性指定了該數(shù)組,并使用id來(lái)引用它,同時(shí)使用bean;write標(biāo)記來(lái)將其顯示出來(lái)。

          還可以通過(guò)length屬性指定輸出元素的個(gè)數(shù),offset屬性指定從第幾個(gè)元素開(kāi)始輸出。例如:

          <logic:iterate id="array1" name="test1" length="3" offset="2">

          <bean:write name="array1"/><br>

          </logic:iterate>

          Struts logic標(biāo)簽(三)

          <logic:match>

          <logic:notmatch>

          該標(biāo)簽用于判斷變量中是否或者是否不包含指定的常量字符串。例如:

          <%

          ??????? pageContext.setAttribute("test","helloWord");

          %>

          <logic:match value="hello" name="test">

          ?????? hello 在helloWord中

          </logic:match>

          Match標(biāo)記還有一個(gè)重要屬性,就是location屬性。location屬性所能取的值只有兩個(gè),一個(gè)是"start",另一個(gè)是"end"。例如:

          <logic:match value="hello" name="test" location="start">

          ????????? helloWord以 hello開(kāi)頭

          </logic:match>

          Struts logic存在標(biāo)簽(四)

          <logic:present>

          <logic:notpresent>

          <logic:messagePresent>

          <logic:messageNotPresent>

          <logic:present>和<logic:notpresent>標(biāo)簽主要用于判斷所指定的對(duì)象是否存在;

          例如:

          <%

          pageContext.setAttribute("test","testString");

          %>

          <logic:present name="test">

          ??????? true??

          </logic:present>

          <logic:present>和<logic:notpresent>標(biāo)記有以下幾個(gè)常用屬性:

          header屬性:???? 判斷是否存在header屬性所指定的header信息。

          parameter屬性:判斷是否存在parameter屬性指定的請(qǐng)求參數(shù)。

          cookie屬性:???? 判斷cookie屬性所指定的同名cookie對(duì)象是否存在。

          name屬性:?????? 判斷name屬性所指定的變量是否存在。

          property屬性:和name屬性同時(shí)使用,當(dāng)name屬性所指定的變量是一個(gè)JavaBean時(shí),判斷property屬性所指定的對(duì)象屬性是否存在。

          <%

          ?????? Cookie cookie=new Cookie("name","value");

          ?????? response.addCookie(cookie);

          %>

          <logic:present cookie="name">

          ??????? true

          </logic:present>

          <logic:messagePresent>和<logic:messageNotPresent>這兩個(gè)標(biāo)記是來(lái)判斷是否在request內(nèi)存在特定的ActionMessages或ActionErrors對(duì)象。它們有幾個(gè)常用的屬性:

          name屬性:???? 指定了ActionMessages在request對(duì)象內(nèi)存儲(chǔ)時(shí)的key值。

          message屬性:message屬性有兩種取值。當(dāng)其為true時(shí),表示使用Globals.MESSAGE_KEY做為從request對(duì)象中獲取ActionMessages的key值,此時(shí)無(wú)論name指定什么都無(wú)效;當(dāng)其為false時(shí),則表示需要根據(jù)name屬性所指定的值做為從request對(duì)象中獲取ActionMessages的key

          值,倘若此時(shí)未設(shè)置name屬性的值,則使用默認(rèn)的Globals.ERROR_KEY。

          property屬性:指定ActionMessages對(duì)象中某條特定消息的key值。

          例如:

          ????? <%

          ???????? ActionErrors errors = new ActionErrors();

          ???????? errors.add("totallylost", new ActionMessage("application.totally.lost"));

          ???????? request.setAttribute(Globals.ERROR_KEY, errors);

          ???????? request.setAttribute("myerrors", errors);

          ????? %>

          ???????? <logic:messagesPresent name="myerrors">

          ?????????? Yes

          ???????? </logic:messagesPresent>

          Struts logic判空標(biāo)簽(五)

          <logic:empty>

          <logic:notEmpty>

          該標(biāo)簽用于判斷指定的字符是否為空。

          例如:

          ????? <%

          ??????? pageContext.setAttribute("test","");

          ????? %>

          ??

          ???? <logic:empty name="test">

          ???????? test 為空

          ???? </logic:empty>

          Struts logic轉(zhuǎn)發(fā)和重定向標(biāo)簽(六)

          1.<logic:foward>轉(zhuǎn)發(fā)標(biāo)簽

          該標(biāo)簽用于進(jìn)行全局轉(zhuǎn)發(fā),使用該標(biāo)簽的頁(yè)面一般不再編寫(xiě)其他內(nèi)容,因?yàn)殡S著轉(zhuǎn)發(fā),頁(yè)面將跳轉(zhuǎn),原頁(yè)面中的內(nèi)容也沒(méi)有意義了。例如:

          ????? this is a test

          <logic:forward name="welcome"/>

          ???? this is a new test

          2.<logic:redirect>重定向標(biāo)簽

          該標(biāo)簽用于進(jìn)行重定向。具有屬性:

          href屬性:???? 將頁(yè)面重定向到href指定的完整外部鏈接。

          page屬性:???? 該屬性指定一個(gè)本應(yīng)用內(nèi)的一個(gè)網(wǎng)頁(yè),標(biāo)記將頁(yè)面重定向到這個(gè)新的網(wǎng)頁(yè)。

          forward屬性:該屬性與struts-config.xml中的<global-forward>內(nèi)的子項(xiàng)相對(duì)應(yīng)。即將頁(yè)面重定向到forward所指定的資源。

          posted @ 2009-07-16 23:51 IT追求者 閱讀(524) | 評(píng)論 (0)編輯 收藏

          struts bean標(biāo)簽使用詳解

          Bean 標(biāo)簽庫(kù)
          ??????? 此標(biāo)簽庫(kù)和Java Bean有很強(qiáng)的關(guān)聯(lián)性,設(shè)計(jì)的本意是要在JSP 和JavaBean 之間提供一個(gè)接口。Struts 提供了一套小巧有用的標(biāo)簽庫(kù)來(lái)操縱JavaBean和相關(guān)的對(duì)象:cookie、 header、 parameter、 define、write、message、 include、page、resource、size、struts。
          -------------------------------
          -------------------------------
          bean:cookie、bean:header、bean:parameter
          這三個(gè)標(biāo)簽用來(lái)重新得到cookie, request header和request parameter。
          bean:header和bean:parameter標(biāo)簽定義了一個(gè)字符串;bean:cookie標(biāo)簽定義了一個(gè)Cookie對(duì)象。你可以使用value屬性做為默認(rèn)值。如果找不到指定的值,且默認(rèn)值沒(méi)有設(shè)定的話,會(huì)拋出一個(gè)request time異常。如果你期望返回多個(gè)值的話,可把multiple屬性設(shè)為true。
          <bean:cookie id="sessionID" name="JSESSIONID" value="JSESSIONID-ISUNDEFINED"/>
          // 這段代碼定義了一個(gè)名為sessionID的腳本變量,如果找不到一個(gè)名為JSESSIONID的cookie,那sessionID


          下面代碼會(huì)輸出一些Cookie對(duì)象的一些屬性:
          <jsp:getProperty name="sessionID " property="comment"/> …
          <jsp:getProperty name="sessionID" property="domain"/> …
          <jsp:getProperty name="sessionID" property="maxAge"/> …
          <jsp:getProperty name="sessionID" property="path"/> …
          <jsp:getProperty name="sessionID" property="value"/> …
          <jsp:getProperty name="sessionID" property="version"/> …

          下面是在request中輸出所有header的例子:
          <%
          ????????? java.util.Enumeration names =((HttpServletRequest) request).getHeaderNames();
          %>

          <%
          ????????? while (names.hasMoreElements()) {
          ????????? String name = (String) names.nextElement();
          %>
          <bean:header id="head" name="<%= name %>"/>
          … <%= name %>
          … <%= head %>

          <%
          ????????? }
          %>

          下面是parameter的例子:
          <bean:parameter id="param1" name="param1"/>
          <bean:parameter id="param2" name="param2" multiple="true"/>??? // 此處定義了一個(gè)param2[]。
          <bean:parameter id="param3" name="param3" value="UNKNOWN VALUE"/>

          于其它標(biāo)簽結(jié)合使用:
          <bean:header id="browser" name="User-Agent"/>
          <P>You are viewing this page with: <bean:write name="browser"/></P>
          ----------------------------------------------------------------------------------------------------------------------------------
          <bean:cookie id="username" name="UserName" scope="session"
          value="New User" />
          <P>Welcome <bean:write name="username" property="value"/!</P>
          ??? // 根據(jù)cookie創(chuàng)建一個(gè)新的Bean,如果用戶名稱已經(jīng)存儲(chǔ)在cookie中,它就不顯示為一個(gè)新用戶。
          -------------------------------
          -------------------------------
          bean:define:有三個(gè)用途。
          一是定義新字符串常量:
          <bean:define id="foo" value="This is a new String"/>
          <bean:define id="bar" value='<%= "Hello, " + user.getName() %>'/>
          <bean:define id="last" scope="session" value='<%= request.getRequestURI() %>'/>
          二是復(fù)制一個(gè)現(xiàn)有的bean給新的bean:
          <bean:define id="foo" name="bar"/>???
          <bean:define id="baz" name="bop" type="com.mycompany.MyClass"/>??? //定義腳本變量的類型,默認(rèn)為Object???
          三是復(fù)制一個(gè)現(xiàn)有的bean的屬性給新的bean:
          <bean:define id="bop" name="user" property="role[3].name"/>
          ??? <bean:define id="foo" name="bar" property="baz" scope="request"??? toScope="session"/>
          ??? //toScope屬性指新bean的scope,默認(rèn)為page??
          上段代碼的意思是把名為bar的bean的baz屬性賦值給foo,foo的類型為String(默認(rèn))。
          -------------------------------
          -------------------------------
          bean:include
          這個(gè)標(biāo)簽和bean:include標(biāo)簽和相似,不同點(diǎn)就是它定義了一個(gè)可以復(fù)用的腳本變量。用id屬性命名一個(gè)新的腳本變量,還支持forward、href、page和transaction.屬性,和html:link中的屬性意義一樣。
          <bean:include id="footerSpacer"??? page="/long/path/footerSpacer.jsp"/>
          然后你能夠在多個(gè)地方(scope為page)調(diào)用:
          <bean:write name="footerSpacer" />

          -------------------------------
          -------------------------------
          bean:message
          用來(lái)實(shí)現(xiàn)對(duì)國(guó)際化的支持的一個(gè)標(biāo)簽,配合java.util數(shù)據(jù)包中定義的Locale和ResourceBundle類來(lái)完成這個(gè)任務(wù),用java.text.MessageFormat類配置消息的格式。
          ??? 首先要指定資源文件的名稱。這個(gè)文件會(huì)包含用默認(rèn)語(yǔ)言編寫(xiě)的在程序中會(huì)出現(xiàn)的所有消息,這些消息以“關(guān)鍵字-值”的形式存儲(chǔ)。文件需要存儲(chǔ)在類路徑下,路徑要作為初始化參數(shù)傳送給ActionServlet。
          ??? 實(shí)現(xiàn)國(guó)際化的規(guī)定:所有的資源文件必須都存儲(chǔ)在基本資源文件所在的目錄中。基本資源文件包含的是用默認(rèn)地區(qū)語(yǔ)言-本地語(yǔ)言編寫(xiě)的消息。如果基本資源文件的名稱是ApplicationResources.properties,那么用其他特定語(yǔ)言編寫(xiě)的資源文件的名稱就應(yīng)該是ApplicationResources_xx.properties(xx為ISO編碼,如英語(yǔ)是en)。因此這些文件應(yīng)包含相同的關(guān)鍵字,但關(guān)鍵字的值是用特定語(yǔ)言編寫(xiě)的。
          ??? 然后,ActionServlet的區(qū)域初始化參數(shù)必須與一個(gè)true值一起傳送,這樣ActionServlet就會(huì)在用戶會(huì)話中的Action.LOCALE_KEY關(guān)鍵字下存儲(chǔ)一個(gè)特定用戶計(jì)算機(jī)的區(qū)域?qū)ο蟆,F(xiàn)在可以運(yùn)行一個(gè)國(guó)際化的web站點(diǎn),它可以根據(jù)用戶計(jì)算機(jī)上的設(shè)置的區(qū)域自動(dòng)以相應(yīng)的語(yǔ)言顯示。

          使用特定的字符串來(lái)替換部分消息:
          在資源文件中的定義:info.myKey = The numbers entered are {0},{1},{2},{3}
          標(biāo)記的使用:<bean:message key="info.myKey" arg0="5" arg1="6" arg2="7" arg3="8"/>
          Jsp頁(yè)面的顯示:The numbers entered are 5,6,7,8??? // 最多支持4個(gè)參數(shù)
          -------------------------------

          -------------------------------
          ?? bean:page:把Jsp中的內(nèi)部對(duì)象做為腳本變量。
          <bean:page id="requestObj" property="request"/>
          -------------------------------
          -------------------------------
          bean:resource:獲得應(yīng)用程序的資源,這個(gè)資源可以是一個(gè)String或從java.io.InputStream中讀入。使用ServletContext.getResource()ServletContext.getResourceAsStream() 方法檢索web應(yīng)用中的資源,如果在檢索資源時(shí)發(fā)生問(wèn)題,就會(huì)產(chǎn)生一個(gè)ruquest time異常。
          <bean:resource id="webxml" name="/WEB-INF/web.xml"/>
          使用input屬性時(shí),資源會(huì)做為一個(gè)InputStream,如果不指定就被當(dāng)成一個(gè)String。

          -------------------------------
          -------------------------------
          bean:size:得到存儲(chǔ)在array、collection或map中的數(shù)目,類型為java.lang.Integer。
          <bean:size id="count" name="employees" />
          -------------------------------
          -------------------------------
          bean:struts:復(fù)制Struct 對(duì)象(三種類型)給新的bean,scope為page。
          <bean:struts id="form" formBean="CustomerForm"/>???
          <bean:struts id="fwd" forward="success"/>
          <bean:struts id="map" mapping="/saveCustomer"/>
          -------------------------------
          -------------------------------
          bean:write:以字符串形式輸出bean的屬性值。
          filter屬性:設(shè)為true時(shí),將HTML保留字轉(zhuǎn)換為實(shí)體("<" 轉(zhuǎn)換為 &lt);
          ignore屬性:如果對(duì)象不存在,不會(huì)拋出異常。
          <bean:write name="userRegistration" property="email" scope="request"/>

          posted @ 2009-07-16 23:13 IT追求者 閱讀(516) | 評(píng)論 (0)編輯 收藏

          struts Html標(biāo)簽使用詳解

          1.html:form 標(biāo)簽
                 該標(biāo)簽的用法必須遵循很多規(guī)則.
                  (1)首先標(biāo)簽中必須包含一個(gè)action屬性,action屬性是該標(biāo)簽唯一一個(gè)必須的屬性.如果沒(méi)有該屬性jsp會(huì)拋出一個(gè)異常,     之后你必須給
          action屬性一個(gè)有效的值,這個(gè)值也就是對(duì)應(yīng)struts配置文件(struts-config.xml)中的action標(biāo)簽中的type屬性值.
                    例如:jsp頁(yè)面中有:<html:form action="/login">
                             則struts-config.xml文件中:
                                                                            <action-mapping>
                                                                                  <action type="/login"
                                                                                                type="對(duì)應(yīng)事件處理類的路徑"
                                                                                                name="對(duì)應(yīng)的formbean"
                                                                                                 />
                                                                              </action-mapping>
                 (2)html:form標(biāo)簽還必須遵循一個(gè)規(guī)則:
                                      任何包含在<form>中用來(lái)接收用戶輸入的標(biāo)簽(<text>、<password>、<hidden>、<textarea>、<radio>、<checkbox>、<select>
          )必須在相關(guān)的form bean中有一個(gè)指定的屬性值.例如,如果你有一個(gè)屬性值被指定為“username”的<text>標(biāo)簽,那么相關(guān)的form bean中也
          必須有一個(gè)名為“username”的屬性。輸入<text>標(biāo)簽中的值會(huì)被用于生成form bean的userName屬性。

          2.html:text標(biāo)簽
                    html:text標(biāo)簽是一個(gè)生成文本框的標(biāo)簽,它必須包含一個(gè)和form bean的相同屬性的對(duì)應(yīng)的"property"屬性.該標(biāo)簽只有嵌套在form中才有效.


          3.html:password標(biāo)簽

                  html:password標(biāo)簽是用來(lái)顯示口令的文本框,它也必須包含一個(gè)和form bean的相同屬性對(duì)應(yīng)的"property"屬性,該標(biāo)簽中的
                   一個(gè)很重要的屬性是“redisplay”,它用于重新顯示以前輸入到這個(gè)區(qū)域中的值。該屬性的缺省值為true。然而,為了
                 使password不能被重新顯示,你或許希望將該屬性的值設(shè)為false。
                  例如:<html:password property="password"/>


          4.html:hadden標(biāo)簽
                    html:hadden是生成一個(gè)隱藏的輸入文本區(qū)域,它必須包含和相關(guān)form bean中的相同屬性對(duì)應(yīng)的“property”屬性。該標(biāo)簽也必須嵌套在form中才有效.
                    例如:<html:hadden property="value"/>


          5.<html:textarea>標(biāo)簽 
                  <html:textarea>標(biāo)簽主要是生成一個(gè)文本域,它必須包含和相關(guān)form bean中相同屬性對(duì)應(yīng)的"property"屬性.該標(biāo)簽也必須嵌套在form中才有效.
                  例如:<html:textarea property="content"
                                                    cols="10"
                                                    rows="5"/>

          6.<html:radio>標(biāo)簽

                      <html:radio>標(biāo)簽是用于顯示一個(gè)單選按鈕.它必須包含"value"值
                     例如:<html:radio property="title" value="1"/>1
                               <html:radio property="title" value="2"/>2
                               <html:radio property="title" value="3"/>3



          7.<html:checkbox>標(biāo)簽


                  <html:checkbox>標(biāo)簽用于顯示checkbox類型的輸入?yún)^(qū)域。比如: <html:checkbox property= 
             "notify">Please send me notification 


          8.<html:submit>標(biāo)簽

                      <html:submit>標(biāo)簽是用于提交按鈕.
                      例如:<html:submit value="提交"/>



          9.<html:reset>標(biāo)簽

                      <html:reset>標(biāo)簽主要是用于重置按鈕


          10.<html:option>標(biāo)簽

                         <option>標(biāo)簽用于顯示select box中的一個(gè)選項(xiàng)。參照下面的<select>標(biāo)簽。 


          11.<html:select>標(biāo)簽

                          <html:select>標(biāo)簽主要是用于顯示下拉列表,它也必須嵌套在form中才有效
                          例如:
                                  <html:select  property="color" size="3">
                                                <html:option  value="red">red</html:option>
                                                <html:option value="green">green</html:option>
                                                 <html:option value="blue">blue</html:option>

           




                     



                      








           

          posted @ 2009-07-16 22:00 IT追求者 閱讀(1633) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 绥德县| 东方市| 原平市| 福贡县| 连山| 郁南县| 新竹市| 荣昌县| 大冶市| 乌鲁木齐县| 云霄县| 安多县| 普兰店市| 铜川市| 鞍山市| 南澳县| 万盛区| 黔西| 虎林市| 阜阳市| 牡丹江市| 旌德县| 吉林省| 嫩江县| 探索| 筠连县| 西充县| 黄石市| 万年县| 宁城县| 丽江市| 晋江市| 佳木斯市| 灵武市| 措勤县| 木兰县| 瑞丽市| 阿巴嘎旗| 辛集市| 天台县| 得荣县|