bean标签库
1. <bean:header> #0968f7
<bean:header id="custlang" name="accept-language"/>
here: <bean:write name="custlang"/>
=>
here: zh-cn,en-us;q=0.5
2. <bean:parameter>
<bean:parameter id="bookid" name="id" value="0"/><%--value是默认值-%>
请求的图书编号为: <bean:write name="bookid"/>
=>
请求的图书编号为: 8 <!-- http://localhost/addressbook/myjsp.jsp?id=8-->
<bean:parameter id="custnames" multiple="true" name="names" value="hehe"/>
请求的客户姓名有: <p/>
<%
for( int i = 0 ; i < custnames.length; i++ ) {
out.print(custnames[i] + "__");
}
%>
=>
请求的客户姓名有: <p/>
cheyo__vsftpd__google__
3. <bean:cookie>
cookies: <bean:cookie id="customer" name="custname" value="cheyo"/>
您好,<bean:write name="customer" property="value"/>
=>
cookies:
您好,cheyo
4. <bean:page>
<bean:page id="currsession" property="session"/>
当前会话创建时间: <bean:write name="currsession" property="creationtime"/>
=>
当前会话创建时间: 1111993122390
5. <bean:message>
<1>
<bean:message bundle="test" key="test.name"/><p/>
<2>
<%
request.setattribute("stringbean", "test.nick");
%>
<bean:message bundle="test" name="stringbean"/>
<3>
<%
somebean bean = new somebean();
bean.setname("hello");
request.setattribute("somebean", bean);
%>
<bean:message bundle="test" name="somebean" property="name"/>
<4>
<bean:message bundle="test" key="test.error" arg0="联系地址!"/>
<!--test.error={0} is requried!-->
6. <bean:resource>
以下为test页面的内容:<p/>
<bean:resource id="testpage" name="test/testds.jsp"/>
<bean:write name="testpage"/>
7. <bean:struts>
<bean:struts id="successforward" forward="aaaa"/>
<bean:write name="successforward" property="path"/>
=>
/hello.jsp
8. <bean:include>
以下为include进的内容:<p/>
<bean:include id="includereg" forward="success"/>
<bean:write name="includereg" filter="false" />
<p/>
以下为include进的内容3:<p/>
<bean:include id="includereg" page="/hello.jsp"/><%--一定要以/开头--%>
<bean:write name="includereg" filter="false" />
9. <bean:define>
<1>
<bean:define id="currdate" value="2005-03-28"/>
<bean:write name="currdate"/>
<2>
<%
user user = new user();
user.setusername("cheyo");
request.setattribute("userbean", user);
%>
<bean:define id="curruser" name="userbean"/>
当前用户姓名: <bean:write name="curruser" property="username"/>
<%-- 注意: 上面加下划线的"user"这一变量名不应与红色下划线的"curruser"这一变量名相同! 否则会报错! -->
10. <bean:size>
<%
hashmap lines = new hashmap();
lines.put("1", "line1");
lines.put("2", "line2");
lines.put("3", "line3");
request.setattribute("lines", lines);
%>
<bean:size id="linesize" name="lines"/>
线的数量:
<bean:write name="linesize"/>
11. <bean:write>
<1>
<%
request.setattribute("floatval", float.valueof("3.14159"));
calendar gc = gregoriancalendar.getinstance();
gc.settime(new date(session.getcreationtime()));
request.setattribute("now", gc);
%>
pi is : <bean:write format="#.####" name="floatval"/><p/>
session started at: <bean:write format="mm-dd-yyyy hh:mm:ss" name="now" property="time"/>
<2>
<%
string boldstart = "<b>";
string boldend = "</b>";
request.setattribute("bs", boldstart);
request.setattribute("be", boldend);
%>
<bean:write name="bs"/>哈哈哈哈<bean:write name="be"/><p/> <%--输出<b>哈哈哈哈</b>--%>
<bean:write name="bs" filter="false"/>加粗的哈哈哈哈<bean:write name="be" filter="false"/><p/>
=>
<b>哈哈哈哈</b><p/>
<b>加粗的哈哈哈哈</b><p/>
新闻热点
疑难解答