Map<Long,Account> map = new HashMap<Long,Account>();
for(int i=0;i<list.size();i++){
Account account = (Account)list.get(i);
map.put(account.getId(),account);
}

后台的

package com.iport.site.controller;

import com.iport.base.basecontroller.BaseController;
import com.iport.exception.SystemException;
import com.iport.site.model.SiteSettingEntity;
import com.iport.site.service.SiteSettingService;
import com.iport.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.*; @Controller
@Scope("prototype")
@RequestMapping("/site/")
public class SiteSettingController extends BaseController { @Autowired
private SiteSettingService siteSettingService; @RequestMapping("listUI.html")
public String listUI(Model model) {
System.out.println("111111111111111111");
try {
List<SiteSettingEntity> list = siteSettingService.querySiteSettingList();
Map<String, String> map = new HashMap<String, String>(); for (int i = 0; i < list.size(); i++) {
SiteSettingEntity siteSettingEntity = list.get(i);
map.put(siteSettingEntity.getKey(), siteSettingEntity.getValue());
}         
model.addAttribute("map", map); //System.out.println("map================" + map.get("SiteName").toString()); return Common.BACKGROUND_PATH + "/site/list";
} catch (Exception e) {
throw new SystemException(e);
}
} }

取值的话就是页面中

${map.key}  或者${map['key']}来显示值

list转map 键值对的更多相关文章

  1. 用字典给Model赋值并支持map键值替换

    用字典给Model赋值并支持map键值替换 这个是昨天教程的升级版本,支持键值的map替换. 源码如下: NSObject+Properties.h 与 NSObject+Properties.m / ...

  2. java 把json对象中转成map键值对

    相关:Json对象与Json字符串的转化.JSON字符串与Java对象的转换 本文的目的是把json串转成map键值对存储,而且只存储叶节点的数据 比如json数据如下: {responseHeade ...

  3. 如何将Map键值的下划线转为驼峰

    本文不再更新,可能存在内容过时的情况,实时更新请移步我的新博客:如何将Map键值的下划线转为驼峰: 例,将HashMap实例extMap键值下划线转为驼峰: 代码: HashMap<String ...

  4. Java Map 键值对排序 按key排序和按Value排序

    一.理论准备 Map是键值对的集合接口,它的实现类主要包括:HashMap,TreeMap,Hashtable以及LinkedHashMap等. TreeMap:基于红黑树(Red-Black tre ...

  5. 枚举类返回Map键值对,绑定到下拉框

    有时候,页面的下拉框要显示键值对,但是不想从数据库取,此时我们可以写一个枚举类, Java后台代码 1.枚举类 import java.util.HashMap; import java.util.M ...

  6. 根据map键值对,生成update与select语句,单条执行语句

    方法 constructUpdateSQL private static String constructUpdateSQL(String tableName, List<Map<Stri ...

  7. Java的map键值对的用法,map的遍历,Entry对象的使用

    思路: 1.定义集合 2.存储数据 3.添加元素 4.遍历 4.1将需要遍历的集合的键封装到set集合中(这用到了entrySet方法,和Entry对象) 4.2声明迭代器或者用for增强循环 4.3 ...

  8. a=av###b=bv###c=cv map键值对 (a,av) (b,bv) (c,cv)

    import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; impo ...

  9. MyBatis返回Map键值对数据

    List<Map<String, String>> getMtypeList(); <select id="getMtypeList" resultT ...

随机推荐

  1. Extract Fasta Sequences Sub Sets by position

    cut -d " " -f 1 sequences.fa | tr -s "\n" "\t"| sed -s 's/>/\n/g' & ...

  2. awk 匹配不是 pattern 的内容

    awk '/pattern/ {next} {print $0}' filename

  3. 3.python算法之完全数

    代码: #!/usr/bin/env python # encoding: utf-8 """ @author: 侠之大者kamil @file: 3.完全数.py @t ...

  4. golang学习之旅:官方文档汇总

    The Go Programming Language Specification:http://localhost:8080/ref/spec学习Constants.Variables.Types. ...

  5. CSS中的a标签几个访问状态记录

    a:link {color: #FF0000}     /* 未访问的链接 */a:visited {color: #00FF00}  /* 已访问的链接 */a:hover {color: #FF0 ...

  6. Bzoj2563 阿狸和桃子的游戏

    Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 701  Solved: 496 Description 阿狸和桃子正在玩一个游戏,游戏是在一个带权图G= ...

  7. 洛谷P1901 发射站

    题目描述 某地有 N 个能量发射站排成一行,每个发射站 i 都有不相同的高度 Hi,并能向两边(当 然两端的只能向一边)同时发射能量值为 Vi 的能量,并且发出的能量只被两边最近的且比 它高的发射站接 ...

  8. POJ 1273 Drainage Ditches

    Drainage Ditches Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 67387   Accepted: 2603 ...

  9. dedecms /member/edit_baseinfo.php SQL Injection Vul

    catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 会员模块中存在的SQL注入 Relevant Link: http:// ...

  10. 分析ffmpeg解析ts流信息的源码

    花费一些时间,然后全部扔了.为了不忘记和抛砖引玉,特发此贴. ffmpeg解析ts流 1.目的     打算软件方式解析出pat,pmt等码流信息 2.源代码所在位置         下载ffmpeg ...