EL表达式怎么获取Map的动态key?】的更多相关文章

缘由 El表达式在调用Map的时候,后台传过来的Map的key不一定是一个固定的值,需要根据另外一个对象的id作为key来put,或者更加复杂的组合id+"string"作为一个key,对于平常使用开固定的key的我来说,以前学过也忘记了,一时想不出怎么做,现在我们来复习一下. 情景 假设有一个情景:我们后台返回一个对象的list,我们根据对象的id作为key放一些关键的值作为value存入Map中.而前台负责显示Map中的关键指标. @RequestMapping(value=&qu…
获取Map集合类中key.value的两种方法 方法一:利用Set集合中的keySet()方法 Map<String,String> map = new HashMap<String,String>(); map.put("name","zhangsan"); map.put("sno","0812"); map.put("cno","3-105"); //将ma…
初学jsp,不清楚cookie的使用方法,希望高手指点一下!   一般来说有两种办法,在JSP中使用Java的嵌入脚本. 例如: 写入Cookie <html> <head>........(中间略) </head> <body> <% String cookieName="Sender"; Cookie cookie=new Cookie(cookieName, "Test_Content"); cookie.…
map.keySet()获取map全部的key值   public static String getUrlWithQueryString(String url, Map<String, String> params) { if (params == null) { return url; } StringBuilder builder = new StringBuilder(url); if (url.contains("?")) { builder.append(&qu…
Jstl是sun的标准taglib库,Jstl是标签库和el语言的结合. el 表达式的隐含对象pageScope,requestScope,sessionScope,applicationScope,比如${hello}语 句首先会从pageScope开始逐个查找scope中的属性,指定域对象语句为${requestScope.hello} 1.与 [ ] 运算符   EL 提供 . 和 [ ] 两种运算符来导航数据.下列两者所代表的意思是一样的: ${sessionScope.user.se…
Map<String, String> map= new HashMap<String,String>(); for(Map.Entry<String, String> entry : map.entrySet()){ if(entry.getValue().equals("符合条件")){ String key = entry.getKey(); } }…
近日碰到奇怪的问题,应该挺好解决的,可是就是卡住我两天 下面我来描述一下问题 用的是springmvc,自然需要controller,假设我现在所有的配置都是对的. controller代码 @RequestMapping(method = RequestMethod.GET) public String update(Model model) { System.out.println("service update"); model.addAttribute("greeti…
今天调试个程序, 有个名为isAdmin的boolean类型的变量在jsp页面获取到的值为空, 这根本就是没获取到或者变量不存在的状况啊,但是在Action中明明是赋值成false了. 上网查了一下有的同学也遇到了这样的问题,这个很好解决,看看代码中isAdmin的get方法, 名字是isAdmin,改成getIsAdmin就好了.原因大家都懂的. 出现这种问题是因为MyEclipse自动生成变量XXX的get和set方法时, 如果变量的类型是boolean,那么get方法的名字就是isXXX,…
在jsp页面中不能通过${list.size}取列表长度,而是 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> list的长度是:${fn:length(list)}…
1.在spring-mvc的配置文件中已经配置jsp的视图解析器 2.在Controller中使用Model的addAttribute方法添加属性name,msg 3.在jsp页面中使用${msg}取msg属性的值失败 4.失败输出 5.解决方法 在需要解析Model或者ModelAndView的jsp页面中添加:<%@ page isELIgnored="false" %> 6.成功输出…