strus标签的使用
●在jsp中指定所使用的标签库url,例如:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
●标签前缀是prefix的值“bean”
以下是标签举例介绍:
一、<bean:message />
1、此标签用来从指定的locale中取回国际化的消息并输出。
2、message代表内容可以通过key直接指定,也可以通过name和property间接的指定,例如:<input type="text" value="<bean:message key="button.claim.Insert"/>" />
3、 key是在国际化配置文件resources 中定义的,例如:
ApplicationResourcesGC.properties中button.claim.Insert=Add
4、struts-config.xml文件中使用来设置message resources文件,例如:<message-resources parameter="resources.ApplicationResourcesGC"/>
二、<bean:write />
1、<bean:write name=“key”/>
相当于<%=request.getAttribute(“key”)%>
;但是后者会识别html格式,前者不会,例如:
<bean:write name=“bean” property="value" filter="true"/>
输出值:<span>Hi<span/>
<%=request.getAttribute(“key”)%>
输出值:Hi
2、属性介绍:
▷name:指定对象名即已经存在的一个Bean,在page,session,request范围中
▷property:指定name所代表的对象的属性名字;
▷filter:指定是否需要屏蔽属性值的html格式,默认为true;
▷format:指定显示的时间,数字,日期等的格式;
▷scope:指定bean的作用范围;
三、<logic:equal />
例:
<logic:equal name="bean" property="value" value="1111">
<div>值为1111</div>
</logic:equal>
属性介绍:
▷name:指定对象名即已经存在的一个Bean,在page,session,request范围中
▷property:指定name所代表的对象的属性名字;
▷value属性:要判断属性的期望值,若和实际值相等则执行标签体里面的内容