posts - 3, comments - 1, trackbacks - 0, articles - 5

          struts Taglib屬于視圖端的技術(shù)
          使用標(biāo)簽有如下優(yōu)點
          一、易于使用,能直接代替在頁面上寫java腳本
          二、便于重用
          struts 標(biāo)簽的配置
          1、在struts-config配置文件中加入標(biāo)簽 <message-resources parameter="MessageResources" />
          2、引入taglib標(biāo)簽庫
             加入<%@ taglib prefix="bean" uri="在struts-taglib.jar包下的META-INF文件夾的tld文件夾下找   到相應(yīng)標(biāo)簽庫的tld文件打開,把uri標(biāo)簽中的值復(fù)制到此處" %>

          <bean:write>標(biāo)簽
          相當(dāng)于jsp標(biāo)簽 <%= %> jsp內(nèi)置對象out.println()方法 做輸出使用
          在相應(yīng)scope內(nèi)設(shè)置值,用<bean:write>標(biāo)簽取出。
          examples:
          取出普通字符串
          <bean:write name="hello"/> 
          name屬性也就是在上一頁面setAttribute()的key。

          以HTML文本形式做輸出
          <bean:write name="hello" filter="false"/> 
          filter="false"文本按HTML形式取出

          格式化日期形式輸出
          <bean:write name="date" format="yyyy-mm-dd HH:mm:ss"/>
          format屬性內(nèi)設(shè)置日期顯示的格式

          格式化數(shù)字
          <bean:write name="num" format="###,###.0000"/> 
          format屬性內(nèi)設(shè)置數(shù)字顯示的格式   數(shù)字顯示格式API在java.text.DecimalFormat中

          對象結(jié)構(gòu)輸出
          對象普通屬性輸出
          <bean:write name="user" property="name"/>
          property="name",引號內(nèi)設(shè)置屬性名,需要符合javaBean規(guī)范
          對象結(jié)構(gòu)屬性輸出
          <bean:write name="user" property="group.name"/>
          property="group.name",使用.進行導(dǎo)航找到結(jié)構(gòu)相應(yīng)屬性.

          <logic:empty><logic:notEmpty><logic:present><logic:notPresent>標(biāo)簽
          這些標(biāo)簽主要用于進行屬性狀態(tài)的判斷
          examples:

          <logic:empty name="att1">
           att1為空
          <br>
          </logic:empty>
          <logic:notEmpty name="att1">
           att1不為空
          <br>
          </logic:notEmpty>
          <logic:present name="att1">
           att1存在
          <br>
          </logic:present>
          <logic:notPresent name="att1">
           att1不存在
          <br>
          </logic:notPresent>


          null值判斷為不存在
          不存在同樣判斷為為空
          空字符串判斷為空,空集合判斷為空

          <logic:terate>迭代標(biāo)簽
          <logic:iterate id="u" name="userList">
          </logic:iterate>
          對集合進行迭代,循環(huán)取出值放在變量u內(nèi)
          examples:

          <logic:iterate id="u" name="userList">
            
          <tr>
             
          <td><bean:write name="u" property="name"></bean:write></td>
             
          <td><bean:write name="u" property="age"></bean:write></td>
             
          <td><bean:write name="u" property="group.name"></bean:write></td>
            
          </tr>
          </logic:iterate>
          主站蜘蛛池模板: 砚山县| 武陟县| 潮州市| 浦东新区| 桑日县| 临猗县| 双桥区| 大庆市| 班戈县| 湘潭市| 义马市| 精河县| 襄樊市| 垣曲县| 五台县| 互助| 河北省| 保德县| 松阳县| 通河县| 宜阳县| 乐业县| 崇左市| 桃源县| 抚州市| 康保县| 长治市| 龙陵县| 宜昌市| 梨树县| 得荣县| 东台市| 玉溪市| 怀化市| 开阳县| 喀什市| 奉化市| 雅江县| 云和县| 通道| 克山县|