When jstl accesses the objects in hashmap in the project, the general routine on the network cannot meet the requirements.
Generally
<%
Map <string, string> MAP2 = new hashmap ();
Map2.put ("A", "Hello World ");
Map2.put ("B", "this is map ");
Request. setattribute ("MAP2", MAP2 );
%>
<Br>
Key-Value Pair traversal <br>
<C: foreach Var = "item" items = "$ {MAP2}">
$ {Item. Key }>$ {item. Value} <br>
</C: foreach>
The above are relatively simple to use.
MeOfCodeRoughly as follows:
<%
..........
List li = call.exe cprocedure (OBJ, sendupdatefile. Class );
List <sendupdatefile>List = new arraylist <Sendupdatefile> ();
// Traverse the set
For (INT I = 0; I <li. Size (); I ++ ){
Sendupdatefile UI = (sendupdatefile) Li. Get (I );
List. Add (UI );
// System. Out. println (ui. tostring ());
}
Pagination P = new pagination ();
P. setindex (tmpcurrpage );
P. setpagesize (tmppagesize );
P. settotle (call. gettotle ());
P. setdata (list );
Request. setattribute ("Upfiles", P );
........
Hashmap <string, dealerbaseinf>List1 = new hashmap <string,Dealerbaseinf> ();
// Traverse the set
For (INT I = 0; I <li1.size (); I ++ ){
Dealerbaseinf UI = (dealerbaseinf) li1.get (I );
List1.put ("" + UI. GETID (), UI );
}
Request. setattribute ("Dealers", List1 );
%>
........
<TD size = "130px" align = "Left"> <select name = "delear" id = "delear"
Style = "width: 120px;">
<Option> select an upstream customer </option>
<C: foreach items ="$ {Dealers}"Var =" item ">
<Option value = "$ {item. Key}">$ {Item. value. name}</Option>
</C: foreach>
</SELECT> & nbsp; <font color = "red"> * </font>
</TD>
.........
<C: foreachItems = "$ {upfiles. Data}"Var ="Li">
<Tr>
<TD align = "center" class = "tab_r1"> <% = ++ I %> </TD>
<TD style = "" align = "center" width = "10%" class = "tab_r1"> <Input
Type = "checkbox" id = "rowid" name = "rowid" value = "$ {Li. ID}"/> </TD>
<TD align = "center" class = "tab_r1">
<C: Choose>
<C: When test = "$ {Li. delear> 0}">
$ {Dealers[Li. delear].Name}
</C: When>
<C: otherwise>
Invalid upstream customer
</C: otherwise>
</C: Choose>
<TD align = "Left" class = "tab_r1"> & nbsp ;$ {Li. filename} </TD>
<TD align = "center" class = "tab_r1" >$ {Li. ftpuptime} </TD>
<TD align = "center" class = "tab_r1" >$ {Li. disflag} </TD>
<TD align = "center" class = "tab_r1" >$ {Li. upoptor} </TD>
</Tr>
</C: foreach>
The following focuses on
1: <C: foreach items ="$ {Dealers}"Var =" item ">
<Option value = "$ {item. Key}">$ {Item. value. name}</Option>
2:$ {Dealers[Li. delear].Name}
Returned item. ValueThe dealerbaseinf object. Name is an attribute of dealerbaseinf.
Delear isThe FK external application key of the dealerbaseinf primary key.
$ {Dealers[Li. delear].Name} The expression is obtained based on the dynamically passed external reference key.
Corresponding name.
Idea Source
If you know the key, write $ {map. key} if the key is a variable, it is written as $ {map [Key]}, for example, map. put ("name", "Zhang San"); string tempval = "name"; $ {map. name }$ {map [tempval]}
Because the value in the [number can be dynamically changed], it is easy to obtain.
Because I am not familiar with jstl, I tested $ {dealers. $ Li. Dealer. name },
$ {Dealers [$ Li. Dealer]. name}, $ {dealers ["$ Li. Dealer"]. name}, both
No, of course, some of them are incorrect statements. test and test are correct.
It will be of great help in accessing complex jstl in the future.