JSPのライフサイクル

JSP网页生成机制解析
本文介绍了JSP作为动态页面生成工具的工作原理。当客户端访问JSP网页时,JSP解析器将其转换为Servlet,再由JSDK编译成Class文件。随后Class文件被加载并执行,最终生成HTML页面发送给客户端浏览器。
   知ってのとおり、JSPはダイナミックページを生成する強力な用具です。しかし、JSPの本質を知っている人は本当に少しいですね!
 JSPウェブはクライアントが訪問する時に、JSPパーサーはこのJSPウェブをServletに翻訳します。そして、JSDKはこのServletをClassファイルに翻訳します。それから、Classファイルはロードされって、実行されります。今、JSPウェブは私たちが望むHTMLページになっかた。後にして、そのHTMLページはクライアントのブラウザに渡されります。
 
<%-- * lxx001.jsp * * 機 能: 人事費用記帳データ入力画面 * * JSPファイル名: LXX001 * * ver 変更日 部課 担当者 変更内容 * ────────────────────────────────── * V01.00.000 '25-04-01 サンプル サンプル 初版 * (C)Copyright 2025 会社名 All rights reserved. * --%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page pageEncoding="Windows-31J"%> <%@include file="../../common/jspheader.jsp"%> <% request.setCharacterEncoding("Shift_JIS"); response.setCharacterEncoding("Shift_JIS"); %> <f:view> <h:form id="lxx001" enctype="multipart/form-data" onsubmit="return doSubmit();"> <h:outputText value="#{boundle.label_lxx001_Title}" /> <!-- ファイル識別ID と 人事費用記帳データを同一行に --> <table class="bgTableBorder" cellspacing="1"> <tr> <td class="labelOneCol"> <h:outputText value="ファイル識別ID:" /> </td> <td class="itemOneCol"> <h:inputText id="fileId" value="#{lxx001MBean.fileId}" required="true" /> </td> <td class="labelOneCol"> <h:outputText value="人事費用記帳データ:" /> </td> <td class="itemOneCol"> <h:inputText id="dataList" value="#{lxx001MBean.dataList}" required="true" /> </td> </tr> <tr> <td class="labelOneCol"> <h:outputText value="ファイル選択:" /> </td> <td class="itemOneCol"> <h:inputFile id="file" value="#{lxx001MBean.file}" required="true" /> </td> <td class="labelOneCol"> <h:outputText value="出力ファイル改訂:" /> </td> <td class="itemOneCol"> <h:inputText id="fileRevision" value="#{lxx001MBean.fileRevision}" required="true" /> </td> </tr> </table> <!-- 残りのフィールド --> <table class="bgTableBorder" cellspacing="1"> <tr> <td class="labelOneCol"> <h:outputText value="支払い区分:" /> </td> <td class="itemOneCol"> <h:selectManyCheckbox id="paymentType" value="#{lxx001MBean.paymentType}"> <f:selectItem itemValue="1" itemLabel="区分1" /> <f:selectItem itemValue="2" itemLabel="区分2" /> </h:selectManyCheckbox> </td> <td class="labelOneCol"> <h:outputText value="対象年月:" /> </td> <td class="itemOneCol"> <h:inputText id="targetYearMonth" value="#{lxx001MBean.targetYearMonth}" required="true" /> </td> </tr> <tr> <td class="labelOneCol"> <h:outputText value="支払い年月日:" /> </td> <td class="itemOneCol"> <h:inputText id="paymentDate" value="#{lxx001MBean.paymentDate}" required="true" /> </td> <td class="labelOneCol"> <h:outputText value="伝票日付:" /> </td> <td class="itemOneCol"> <h:inputText id="voucherDate" value="#{lxx001MBean.voucherDate}" required="true" /> </td> </tr> <tr> <td class="labelOneCol"> <h:outputText value="過帳日付:" /> </td> <td class="itemOneCol"> <h:inputText id="postingDate" value="#{lxx001MBean.postingDate}" required="true" /> </td> <td class="labelOneCol"> <h:outputText value="従業員コード:" /> </td> <td class="itemOneCol"> <h:inputText id="employeeCode" value="#{lxx001MBean.employeeCode}" required="true" /> </td> </tr> <tr> <td class="labelOneCol"> <h:outputText value="範囲選択:" /> </td> <td class="itemOneCol"> <h:selectOneMenu id="selectionType" value="#{lxx001MBean.selectionType}" required="true"> <f:selectItem itemValue="1" itemLabel="範囲1" /> <f:selectItem itemValue="2" itemLabel="範囲2" /> </h:selectOneMenu> </td> <td class="labelOneCol"> <h:outputText value="出力先:" /> </td> <td class="itemOneCol"> <h:selectOneMenu id="destination" value="#{lxx001MBean.destination}" required="true"> <f:selectItem itemValue="client" itemLabel="クライアント" /> <f:selectItem itemValue="server" itemLabel="サーバ" /> </h:selectOneMenu> </td> </tr> </table> <!-- ボタン --> <h:commandButton id="saveBtn" value="保存" action="saveBtn" styleClass="button" /> <h:commandButton id="cancelBtn" value="キャンセル" action="cancelBtn" styleClass="button" /> </h:form> </f:view>代码修改,让前三个字段占两行,第一个跟第二个占一行,第二个独占一行,然后下面留一个格子的空白处,接下来的所有字段都独占一行
07-24
<%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!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="${ctxPath}/components/searchView/script/jquery-3.7.1.min.js"></script> </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:${strMenuDisp6};width: max-content;" 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:${strMenuDisp12};width: max-content;" 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> <c:forEach items="${infoList}" var="map"> <tr> <td> <span class="warning-icon" style="display: ${map.優先フラグ == '1' ? '' : 'none'};">!</span> </td> <td>${map.お知らせ}</td> </tr> </c:forEach> </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> 这代码里面<% Date now = new Date(); String historicalTime = StringUtil.seirekiToWareki(now, StringUtil.WarekiFormat.SHORT_DATE); %>报错 没有引用具体的date和StringUtil 我应该怎么引用
最新发布
10-18
帮我把这里的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
<%@ 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> .topBody { background-color: #EEEEEE; text-align: center; margin: 0; padding: 0 0 20px; border-top-style: none; } </style> </head> <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); } </script> <% 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> //マニュアルボタン押下プロセス 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-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值