<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Map 的取得某一个key的值, OK!<br/>
参考:http://blog.csdn.net/hakunamatata2008/archive/2010/02/07/5295500.aspx
This is my JSP page. <br/>
方法一:<br/>
直接取值的调用方式: <s:property value="powerMap['powerright_'+3]"/><br/>
有变量直接取值的调用方式: <s:property value="powerMap['powerright_'+powerRightsVO.power]"/>
方法二:<br/>
<s:set name="myMapKey" value="'powerright_'+powerRightsVO.power"></s:set>
<s:property value="#myMapKey"/> <br/>
<s:property value="powerMap[#myMapKey]"/><br/>
<s:if test="powerMap[#myMapKey] != null ">
我的值:<s:property value="powerMap[#myMapKey]" /><br/>
test时,不需要用 ${}
</s:if>
<s:if test="powerMap[''+#myMapKey] != null ">
我的值:powerMap[''+#myMapKey] 也行!<br/>
</s:if>
<s:if test="powerMap[#myMapKey] == true">
我的值为true:<s:property value="powerMap[#myMapKey]" /><br/>
</s:if>
<br/>
<s:iterator value="powerMap" id="column">
• <s:property value="#column"/><br>
<s:property value="#column.key"/><br>
• key: <s:property value="key"/><br>
• value:<s:property value="value"/><br>
• </s:iterator>
如果value是对象,直接再加点进行取得对应的属性。
</body>
</html>