-
properties파일에서 설정한 변수 jsp에서 사용하기WEB & CS 2023. 8. 11. 18:50
spring:eval 태그를 사용해 설정하기
1. dispatcher-servlet.xml 파일에 사용할 properties 경로 설정하기
// * 위에 bean태그 안에 util을 사용하기 위해 추가 xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd" <util:properties id="sysGlobals" location="classpath:properties 파일 경로" />2. jsp에서 사용할 변수 설정
// jsp 상단에 작성 <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <spring:eval expression="@sysGlobals['url']" var="urlReport"/>- sysGlobals : dispatcher-servlet.xml에서 설정한 id 값
- url : properties 파일에서 설정한 변수
- urlReport : jsp에서 사용할 변수명
3. jsp에서 ${urlReport}로 properties변수 사용
jsp 상단에 경로 설정해 사용하기
<%@ page import="properties 변수를 설정한 globals파일 패키지 경로" %> var reportUrl = "<%=globals파일명.설정된 변수명%>";'WEB & CS' 카테고리의 다른 글
Sync & Async & Blocking & Non-Blocking (0) 2023.08.11 자료구조 시작 전 사전지식_linkedList (0) 2023.08.11 CORS 에러 정리(2)_시나리오 (0) 2023.08.11 CORS 에러 정리(1) (0) 2023.08.11 알고리즘 시간 복잡도(Time Complexity) (0) 2023.04.25