EL表达式获取List<Map<String, Object>>中的map的值

本文介绍了一种Java后台与JSP页面进行数据交互的方法,通过使用`util.getPropertyName`获取配置信息,并将数据封装成JSON格式传递给前端。前端则利用JSTL标签`c:forEach`进行数据展示。

后台controller

 String nbfylr=util.getPropertyName("logiInfo.function.wlsq_wx01_nbfylr");
 model.addAttribute("nbfylrList", JSONArray.fromObject(this.logiInfoService.getWlxxDataMap(nbfylr, params)));

jsp

<!--循环便利-->

<c:forEach  items="${nbfylrList}" var="list"> 

${list['bfkcl']}

</c:forEach >

<!--也可以单个获取第一个中的某个map属性-->

${nbfylrList.get(0)['bfkcl']}

帮我把这里的java代码提出来 放在一个servlet中 <%@ page contentType="text/html; charset=UTF-8" import="jakarta.servlet.http.HttpSession" import="java.util.*" import="jakarta.servlet.http.HttpSession" import="jp.co.canon_soft.wp.runtime.util.*" import="security.MenuDisp" import="util.StringUtil" import="org.apache.commons.lang.*" import="jp.co.canon_soft.wp.runtime.AppContext" import="common.CommonMethod"%> <% String ctxPath = request.getContextPath(); String pAction = request.getParameter("action"); HttpSession ses = request.getSession(true); String userId = StringUtil.toString(ses.getAttribute("APP_USER")); Date sysLastLoginDateTime = (Date) ses.getAttribute("sysLastLoginDateTime"); String lastLoginTime = ""; //前回ログイン日時和暦形式 if (sysLastLoginDateTime != null) { lastLoginTime = StringUtil.seirekiToWareki(sysLastLoginDateTime, StringUtil.WarekiFormat.LONG_DATETIME); } String strMenuNm6 = ""; String strMenuNm12 = ""; String strMenuNm14 = ""; String strNone = "none"; String strMenuDisp6 = strNone; String strMenuDisp12 = strNone; String strMenuDisp14 = strNone; String strRootUrl6 = ""; String strRootUrl12 = ""; String strRootUrl14 = ""; //表示メニュー情報取得 List<Map<String, Object>> resultList = MenuDisp.getGyoumuAndKanriMenu(userId); String userName = StringUtil.toString(resultList.get(0).get("氏名")); String userShozoku = StringUtil.toString(resultList.get(0).get("所属")); if (resultList.size() > 0) { ses.setAttribute("APP_USERNAME", resultList.get(0).get("氏名")); ses.setAttribute("APP_SHOZOKUNAME", resultList.get(0).get("所属")); for (int i = 0; i < resultList.size(); i++) { Map<String, Object> map = resultList.get(i); String menuOrder = StringUtil.toString(map.get("メニュー順")); String strMenuNm = StringUtil.toString(map.get("メニュー名称")); String strMenuId = StringUtil.toString(map.get("メニューID")); if ("PS".equals(strMenuId)) { strMenuNm14 = strMenuNm; strMenuDisp14 = ""; strRootUrl14 = strMenuId; } else { switch (menuOrder) { case "6" : strMenuNm6 = strMenuNm; strMenuDisp6 = ""; strRootUrl6 = strMenuId; break; case "12" : strMenuNm12 = strMenuNm; strMenuDisp12 = ""; strRootUrl12 = strMenuId; break; } } } } List<Map<String, Object>> infoList = CommonMethod.getInformation("CM"); %> <!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta http-equiv="Content-Style-Type" content="text/css"> <title>財務会計システム</title> <link rel="stylesheet" href="<%=ctxPath%>/style/global.css"> <link rel="stylesheet" href="<%=ctxPath%>/style/body_global.css"> <link rel="stylesheet" href="<%=ctxPath%>/style/login2.css"> <link rel="stylesheet" href="<%=ctxPath%>/font-awesome/css/font-awesome.css" /> <script src="<%=AppContext.getContextPath()%>/components/searchView/script/jquery-3.7.1.min.js" type="text/javascript"></script> <style> </style> </head> <% Date now = new Date(); String historicalTime = StringUtil.seirekiToWareki(now, StringUtil.WarekiFormat.SHORT_DATE); %> <body class="topBody"> <div class="topHeader topHeaderWide"> <div> <h1 class="topHeaderTitle">財務会計システム</h1> </div> <div class="topHeaderMenu"> <div id="downloadDiv" class="btnManual">マニュアル</div> <div class="btnLogout" onclick="login()">ログアウト</div> </div> <div class="topHeaderUserdata" id="divUserInfo"> <dl> <dt class="userOrganization" style="font-size: 16px;">所属</dt> <dd class="userOrganizationData"> <span style="font-size: 16px;"><%=userShozoku%></span> </dd> <dt class="userName" style="font-size: 16px;">氏名</dt> <dd class="userNameData"> <span style="font-size: 16px;"><%=userName%></span> </dd> </dl> </div> <div class="topHeaderDate"><%=historicalTime%></div> </div> <div class="topContainerWide" style="padding: 1px 0px;"> <div class="topContainerInner"> <div class="topContainerLogindate"> <span style="color: #148FC7; font-size: 12px;">前回ログイン日時:<%=lastLoginTime%></span> </div> <div class="topContainerColFlex"> <div class="topContainerCol" style="width: 49%;"> <h2>業務システム</h2> <div style="padding: 0; margin: 0; width: 100%;"> <div class="portalMenulist listCol2" style="float: left; width: 50%"> <div style="padding-left:15px;display:;width: max-content;<%=strMenuDisp6%>;" id="div表示メニュー6"> <a onclick="opensayibu('<%=strRootUrl6%>');" target='hgnew' id="hpl表示メニュー6"> <span class="right-icon">></span><span id="lbl表示メニュー6" style="font-size: 18px;"> <%=strMenuNm6%></span> </a> </div> </div> <div class="portalMenulist listCol2" style="float: left; width: 50%"> <div style="padding-left:100px;display:;width: max-content;<%=strMenuDisp12%>;" id="div表示メニュー12"> <a onclick="opensayibu('<%=strRootUrl12%>');" target='hgnew' id="hpl表示メニュー12" style="margin-left: -50px;"> <span class="right-icon">></span><span id="lbl表示メニュー12" style="font-size: 18px;"> <%=strMenuNm12%></span> </a> </div> </div> </div> </div> <div class="topContainerCol" style="width: 49%;"> <h2>管理</h2> <div class="portalMenulist listCol2" style="float: left; width: 50%"> <div style="margin-left: -122px;display:<%=strMenuDisp14%>;" id="div表示メニュー14"> <a onclick="opensayibu('<%=strRootUrl14%>');" target='hgnew' id="hpl表示メニュー14" style="margin-left: 166px;"> <span class="right-icon">></span><span id="lbl表示メニュー14" style="font-size: 18px;"> <%=strMenuNm14%></span> </a> </div> </div> </div> </div> <form name="myLogin" method="POST" action="<%=ctxPath%>/page/Login.jsp"> <input type="hidden" name="action" value="doMenulogin"> <input type="hidden" name="menuId" id="menuId" value=""> <div style="display: flex; gap: 20px; height: 130px;"></div> </form> <hr> <div> <h3>・お知らせ・</h3> </div> <div class="topContainerCautionBox" style="padding-right: 50px;"> <div class="topContainerCautionBox" style="overflow-y: auto; height: 120px; width: 100%; margin: 0;"> <table> <tr> <td></td> </tr> <% for (int i = 0; i < infoList.size(); i++) { Map<String, Object> map = infoList.get(i); String display = ("1".equals(map.get("優先フラグ"))) ? "" : "none"; %> <tr> <td><span class="warning-icon" style=" display:<%=display%>;">!</span></td> <td><%=map.get("お知らせ")%></td> </tr> <% } %> </table> </div> </div> <div class="cautionList" style="margin-left: 200px;"> <li>※財務会計システムでは誤作動防止のため、以下のブラウザ標準機能を制御しておりますのでご注意ください。 <br> ・マウス操作による右クリック・メニューが表示されません。<br> ・キーボードのBS(バックスペース)キーで前画面に戻れません。 </li> </div> <hr> </div> <div class="cautionList"> <div style="margin-right: 443px;"></div> </div> <div style="width: 100%; display: flex;"> <div style="width: 50%; text-align: left; margin-left: 50px; font-size: 13px"> Ver.1.0.0</div> <div style="width: 50%; text-align: right; margin-right: 50px; font-size: 13px"> 画面ID:CMM010DB</div> </div> </div> <script> /* * メニューIDに応じてサブ画面処理を開く */ function opensayibu(menuID) { const width = 1920; const height = 1080; const screenWidth = window.screen.width; const screenHeight = window.screen.height; let left = (screenWidth - width) / 2; let top = (screenHeight - height) / 2; document.getElementById("menuId").value = menuID; const origin = window.location.origin; // 該当パスを取得 const pathname = window.location.pathname; // プロジェクトを取得 const projectName = pathname.split('/')[1]; const newURL = origin + "/" + projectName + "/_link.do"; const childUrl = origin + "/" + projectName + "/_link.do"; openWindow = window.open('', 'hgnew', 'width=1920,height=1080,top=' + top + ',left=' + left + ',status=yes,resizable=yes,scrollbars=yes,toolbar=no'); const form = document.createElement('form'); form.method = 'POST'; form.action = newURL; form.target = 'hgnew'; if (menuID == "RS") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'RS'; form.appendChild(input); } else if (menuID == "KI") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'KI'; form.appendChild(input); } else if (menuID == "KS") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'KS'; form.appendChild(input); } else if (menuID == "DK") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'DK'; form.appendChild(input); } else if (menuID == "ZK") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'ZK'; form.appendChild(input); } else if (menuID == "PS") { let input = document.createElement('input'); input.type = 'hidden'; input.name = 'SYSKBN'; input.value = 'PS'; form.appendChild(input); } document.body.appendChild(form); form.submit(); document.body.removeChild(form); // 100ミリ秒間隔で子画面の状態を監視 const interval = setInterval(function() { // 子画面が閉じていたら if (!openWindow || openWindow.closed) { // Intervalを破棄 clearInterval(interval); } else { // 子画面にフォーカスを当てる if (!openWindow.document.hasFocus()) { openWindow.focus(); } } }, 100); } //マニュアルボタン押下プロセス const downloadDiv = document.getElementById('downloadDiv'); const resourceUrl = '/FinancialCoreSystem/file/manual.zip'; const notFoundUrl = '/FinancialCoreSystem/file/manual.zip'; const fileName = 'manual.zip'; downloadDiv.onclick = function () { fetch(resourceUrl, { method: 'HEAD' }) .then(response => { if (!response.ok) { window.location.href = notFoundUrl; return; } const a = document.createElement('a'); a.href = resourceUrl; a.download = fileName; document.body.appendChild(a); a.click(); document.body.removeChild(a); }) .catch(() => { window.location.href = notFoundUrl; }); }; //ログアウトボタン押下プロセス function login() { window.location.href = "/FinancialCoreSystem/page/login.jsp"; } </script> </body> </html>
最新发布
10-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值