Use the iterator tag Struts2 nested traversal Map <String, List <TypeInfo>>

2009-08-02  来源:本站原创  分类:Java  人气:283 

First, the database structure is so
1. Type ID typeId
2. Type name typeName
3. Parent type ID parentsId
Rather with a tree so the tree's roots parentsId are 0
Belong to the root node parentsId are under the tree typeId
So I check out the results from the database into the Map where the structure is so

First, from the database query out of the tree so the root node (that is, parentsId equal to 0) into the List in the List and then into the Map in the key to "0" is parentsId the value of the column and then traverse the List to get each of the root node typeId to the database query child nodes belonging to root and to belong to the root node's child nodes and then saved to the List in the preservation of the Map in the List key is the value of the child node parentsId

Page traversal methods are:

<ul>
                <li><a href="#"><span><strong> All article  (123)</strong></span></a></li>
                <s:iterator var="classificationroot" value="classifications['0']">
                <li>
                        <a href="javaScript:flkz('javabc<s:property value="#classificationroot.classificationId"/>')"><span><strong><s:property value="#classificationroot.typesName"/>(90)</strong></span></a>
                    <ul#classificationroot.classificationId"/>">
                        <s:iterator var="classification" value="classifications[#classificationroot.classificationId]">
                                <li><a href="#"><span><s:property value="#classification.typesName"/></span></a></li>
                        </s:iterator>
                    </ul>
                </li>
                </s:iterator>
            </ul>

The first iterator is the root of the second iterator is traversing traverse child nodes belonging to the root of the

classifications Map name of the object classifications ['0 '] to get key value is 0, so that value is the root node and traverse it to get List of typeId the value of the root node, and then traversing through the second iterator belong to the root of the sub - node.
Note: The second iterator's value attribute value = "classifications [# classificationroot.classificationId]" of the sampling method is

相关文章
  • Use the iterator tag Struts2 nested traversal Map <String, List <TypeInfo>> 2009-08-02

    First, the database structure is so 1. Type ID typeId 2. Type name typeName 3. Parent type ID parentsId Rather with a tree so the tree's roots parentsId are 0 Belong to the root node parentsId are under the tree typeId So I check out the results from

  • Struts2 nested traversal List 2008-05-14

    1.struts2 nested traversal list (list in the Action in the need to setAttribute ()) <s:iterator value="#request.projecttypes"> ${one.name} <s:iterator value="projectinfos"> <a href="${two.project_id}">${two.

  • Struts2 iterator tag 2010-08-05

    struts2 the s: iterator to traverse the data stack inside any array, collection, etc. Here are some simple demo: 1.s: iterator tag has three attributes: value: is the set of iterations id: the specified id elements inside the collection status index

  • struts2 traversal Map 2010-03-19

    Today visit the post, to see a useful post, dig it over to study, for later use. Address http://neil-jh.javaeye.com/blog/316903 original quote For example, I have a map of this structure private Map <String, List <HotelRoomTypeView>> viewMap =

  • struts2 iterator tag related to the use of 2010-07-07

    English Title: (Turn) of label of the Iterator in Struts2 relevant use In explaining the s: iterator tag used before to understand the next struts2 in Value Stack. Here to the webwork in the description on the Value Stack, as struts2 is based on the

  • Struts2 iterator tag usage 2010-12-03

    In explaining s: iterator tag before use, to understand in the next struts2 Value Stack. Webwork here in reference to the description of the Value Stack, as struts2 is upgraded on the basis of webwork, so webwork representation for the Value Stack al

  • struts iterator tag usage Xiangjie 2008-05-27

    struts2 of the s: iterator to traverse the data inside the stack of any array, collection, and so following a few simple demo: s: iterator tag has three attributes: value: being a collection of iterative id: the element inside the specified collectio

  • Usage of struts iterator tag 2010-03-16

    struts2 the s: iterator to traverse the data stack inside any array, collection, etc. Here are some simple demo: s: iterator tag has three attributes: value: is the set of iterations id: the specified id elements inside the collection status index of

  • (Transfer) STRUTS2.0 used tags struts2 tag struts2 2010-10-13

    1. Struts2 tag page developers for use in the common 1.1. To the action in the use-value: <input name="userName" type="text" size="15"> a. userName attribute to access the action need to provide the appropriate properti

  • struts2 nested with the iframe, the data show the problem 2010-11-13

    struts2 nested with the iframe, the data show problems. we see the figure below, I explain below: This is the company to do a system do not use sitemesh, the direct use of the iframe, specifically why, this is not discussed in this The current system

  • struts2.0 traversal control <s:iterator> 2010-08-16

    struts2.0 traversal control <s:iterator> the index status: 1: odd (odd) 2: first (first index) 3: even (even) 4: last (tail index) 5: index (index entry) <%@ page contentType="text/html; charset=UTF-8" %> <%@ page import="jav

  • Universal traversal Map 2010-10-27

    Java code Map map = new HashMap (); Iterator it = map.entrySet (). Iterator (); while (it.hasNext ()) { Map.Entry entry = (Map.Entry) it.next (); Object key = entry.getKey (); Object value = entry.getValue (); } JDK1.5, the application of the new For

  • Traversal map of the elements of several methods 2009-04-09

    import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; / ** * Traverse the map in several ways * @ Author tpf * * / public class TestMapLookup ( public static void main (String [] args) ( Map <String,Integer>

  • jstl EL expression traversal Map 2010-09-24

    In EL, the square brackets operator is used to retrieve the array and the elements of the collection. Java.util.Map interface for achieving the set of square brackets operator with the associated keys to find the value stored in the map. Key specifie

  • struts标签绑定Map String, List Map String, Object 2014-04-15

    早先时候已经有一篇写到struts的iterator标签去遍历些基本的集合数据了,比如单个对象的List啊,多个对象的List啊,map等等.最近呢又遇见两种情况,在这里给记录一下,方便自己以后能随时查看,也希望能在一定程度上帮助到大家. 第一种情况是,这里首先有两个表,一个表是客户表(CustomerInfo),一个表是收货人表(TakerInfo),两个表中,都有姓名(name)和电话(cellphone)的属性,根据页面输入的一系列条件,如name,cellphone等去查询两表,得到一个

  • 解析(map[string]interface{})数据格式并打印出数据 2013-11-22

    学习golang 记录下 //解析(map[string]interface{})数据格式并打印出数据 func print_json(m map[string]interface{}) { for k, v := range m { switch vv := v.(type) { case string: fmt.Println(k, "is string", vv) case float64: fmt.Println(k, "is float", int64(v

  • javaBean与Map String,Object 互转 2014-04-15

    1. 为什么要实现javaBean与Map<String,Object>相互转换? 用过spring的都知道spring的MVC框架中有一个BaseCommandController对象,利用这个对象我们就可以很方便的将从客户端传递过来的参数封装到一个JavaBean对象中去,而不需要我们request.getParameter("name");bean.setName(name);了,从而也简化了不少的工作.如果大家用过BeanUtils.populate的话,就知道,这

  • Map String,List String 转为List Map String,String 2014-07-25

    /** * * @param map 输入 * @param list 输出 * @param idx 次序 * @param pathMap 已选 */ void map2List(Map<String, List<String>> map, List<Map<String, String>> list, int idx, HashMap<String,String> pathMap){ if(null == pathMap){ pathMap

  • Struts2 iterator tag values using <s:iterator> 2011-01-11

    ----------------------------------------------------------sturts.xml <action name="FindAllusersAction"> <result name="list">/list.jsp</result> </action> ---------------------------------------------------------

  • Struts2 in combination traversal MAP LIST Set, etc. 2010-04-09

    java code List list = new ArrayList (); Map listmap = new HashMap (); list.add ( "1111111"); list.add ( "2222222"); list.add ( "3333333"); list.add ( "4444444"); listmap.put ( "1", list); <s:iterator va