Struts1.2.4学习心得!(三)

第三次学习:

1.从Bean中取得数组并显示(其中intArray为BEAN返回的数组)

java代码:

1
2 <jsp:useBean id="test3" scope="page" class="org. apache. struts. webapp. exercise. TestBean" />
3 <table border=" 1">
4 <tr>
5 <th>Correct Value</th>
6 <th> Array Result</th>
7 <th>Indexed Result</th>
8 </tr><% for ( int index = 0; index < 5; index++ ) { %>
9 <tr>
10 <td>
11 <%= index * 10 %>
12 </td>
13 <td>
14 <bean:write name="test3" property= '<%= "intArray[" + index + "]" %>' />
15 </td>
16 <td>
17 <bean:write name="test3" property= '<%= "intIndexed[" + index + "]" %>' />
18 </td>
19 </tr><% } %>
20 </table>
21





2.嵌套Bean的属性的显示(nested为TestBean的一个属性,nested为一个bean.显示nested中的属性值)

java代码:

1
2<jsp:useBean id="test5" scope="page" class="org. apache. struts. webapp. exercise. TestBean" />
3 <table border=" 1">
4 <tr>
5 <th>Data Type</th>
6 <th>Correct Value</th>
7 <th>Test Result</th>
8 </tr>
9 <tr>
10 <td> boolean</td>
11 <td>
12 <jsp:getProperty name="test5" property="booleanProperty" />
13 </td>
14 <td>
15 <bean:write name="test5" property="nested. booleanProperty" />
16 </td>
17 </tr>
18 <tr>
19 <td> double</td>
20 <td>
21 <jsp:getProperty name="test5" property="doubleProperty" />
22 </td>
23 <td>
24 <bean:write name="test5" property="nested. doubleProperty" />
25 </td>
26 </tr>
27 <tr>
28 <td>float</td>
29 <td>
30 <jsp:getProperty name="test5" property="floatProperty" />
31 </td>
32 <td>
33 <bean:write name="test5" property="nested. floatProperty" />
34 </td>
35 </tr>
36 <tr>
37 <td> int</td>
38 <td>
39 <jsp:getProperty name="test5" property="intProperty" />
40 </td>
41 <td>
42 <bean:write name="test5" property="nested. intProperty" />
43 </td>
44 </tr>
45 <tr>
46 <td>long</td>
47 <td>
48 <jsp:getProperty name="test5" property="longProperty" />
49 </td>
50 <td>
51 <bean:write name="test5" property="nested. longProperty" />
52 </td>
53 </tr>
54 <tr>
55 <td>short</td>
56 <td>
57 <jsp:getProperty name="test5" property="shortProperty" />
58 </td>
59 <td>
60 <bean:write name="test5" property="nested. shortProperty" />
61 </td>
62 </tr>
63 <tr>
64 <td> String</td>
65 <td>
66 <jsp:getProperty name="test5" property="stringProperty" />
67 </td>
68 <td>
69 <bean:write name="test5" property="nested. stringProperty" />
70 </td>
71 </tr>
72 </table>
73



3.嵌套bean中数组的显示(nested为TestBean的一个属性,nested为一个bean.显示nested中的数组的属性值)

java代码:

1
2 <jsp:useBean id="test6" scope="page" class="org. apache. struts. webapp. exercise. TestBean" />
3 <table border=" 1">
4 <tr>
5 <th>Correct Value</th>
6 <th> Array Result</th>
7 <th>Indexed Result</th>
8 </tr><% for ( int index = 0; index < 5; index++ ) { %>
9 <tr>
10 <td>
11 <%= index * 10 %>
12 </td>
13 <td>
14 <bean:write name="test6" property= '<%= "nested.intArray[" + index + "]" %>' />
15 </td>
16 <td>
17 <bean:write name="test6" property= '<%= "nested.intIndexed[" + index + "]" %>' />
18 </td>
19 </tr><% } %>
20 </table>
21

你可能感兴趣的:(apache,bean,jsp,struts)