bean标签的使用方法

项目引入struts后,在WEB-INF中会生成c.tld,struts-html.tld,struts-logic.tld等文件

在jsp中引用相应标签的tld文件。jsp中taglib里的uri和prefix分别对应tld文件中的uri和short-name:

<%@ taglib uri="http://struts.apache.org/tags-bean"  prefix="bean"%>

1.<bean:write格式化输出:

<logic:iterator    id="fwxx"     name="list">    此处id是随便起的元素别名,与下面的name值对应;name是一个集合

    <bean:write    name="fwxx"    property="zj"    format="#,###"/>元

    <bean:write    name="fwxx"    property="date"    format="yyyy年MM月dd日"/>  //冒似fwxx对象必须有getDate()方法

</logic:iteartor>

2.<bean:define定义页面变量:

<bean:define    id=""dataList     type="java.util.List"    name="list"    scope="request"/>     ——————>在request范围中取出list集合并重新命名为dataList

    共找到<%=dataList.size()%>条数据

</bean:define >

3.<bean:size得到集合中数据总数:

<bean:size    id="count"    name="list"/>

共找到${count}条记录

4.<bean:message取得国际化资源

例如国际化资源中有:info.myKey = The numbers entered are {0},{1},{2},{3}
jsp中:<bean:message key=”info.myKey” arg0=”5” arg1=”6” arg2=”7” arg3=”8”/>
显示为:The numbers entered are 5,6,7,8

国际化编码语言转化:1.cmd——>native2ascii.exe

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/shipeng22022/p/4614194.html