Notes
Bean Tag Library
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 is the default value-%>
The requested book number is: <bean:write name= "BookID"/>
=>
The requested book number is: 8 <!--http://localhost/addressbook/myjsp.jsp?id=8-->
<bean:parameter id= "Custnames" multiple= "true" name= "names" value= "hehe"/>
The requested customer name is: <p/>
<%
for (int i = 0; i < custnames.length; i++) {
Out.print (Custnames[i] + "__");
}
%>
=>
The requested customer name is: <p/>
cheyo__vsftpd__google__
3. <bean:cookie>
Cookies: <bean:cookie id= "Customer" name= "CustName" value= "Cheyo"/>
Hello, <bean:write name= "Customer" property= "value"/>
=>
Cookies:
Hello, cheyo.
4. <bean:page>
<bean:page id= "Currsession" property= "Session"/>
Current session creation time: <bean:write name= "currsession" property= "CreationTime"/>
=>
Current session creation time: 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= "Contact address!" />
<!--test.error={0} is requried!-->
6. <bean:resource>
The following is the content of the test page:<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>
The following are the contents of include:<p/>
<bean:include id= "Includereg" forward= "Success"/>
<bean:write name= "Includereg" filter= "false"/>
<p/>
The following are the contents of include 3:<p/>
<bean:include id= "Includereg" page= "/hello.jsp"/><%--must take/start--%>
<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"/>
Current user name: <bean:write name= "Curruser" property= "UserName"/>
<%--Note: The underlined "user" variable name should not be the same variable name as the red underline "Curruser"! Otherwise it will be an error! -->
<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"/>
Number of lines:
<bean:write name= "Linesize"/>
One. <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"/> haha <bean:write name= "be"/><p/> <%--output <B> haha haha </B>--%>
<bean:write name= "BS" filter= "false"/> bold haha <bean:write name= "be" filter= "false"/><p/>
=>
<B> haha haha </B><p/>
<B> bold haha </B><p/>