일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- nodejs
- JDBC
- servlet
- 대덕인재개발원
- ddit
- python
- 자바문제
- Error
- jsp
- 맥
- 단축키
- Java
- Homebrew
- spring
- 객체지향
- ibatis
- 반복문
- 자바
- html
- 컬렉션프레임워크
- API
- Android
- 생활코딩
- FastAPI
- Oracle
- Mac
- 이클립스
- crud
- 배열
- pyqt
Archives
- Today
- Total
romworld
JSP 17 - Properties File Editor (다국어 처리) ,JSTL fmt 활용 본문
1. fmt를 활용할 수 있다
<%@ taglib prefix="fmt">
- 날짜
- bundle
- 숫자
2. bundle
- java.util.properties
- 위치 : src/패키지
- 파일 확장자 : .properties
- 언어구분 : 한글 -kr 영어 -en
- 국제화 : i18n
- 지역화 : L10n
다국어 처리
1. ctrl + n -> file- > properties
Downloading File /eclipse/updates - Properties Editor - OSDN
Free download page for Project Properties Editor's updates.This editor can directly edit property files written in Unicode reference characters, eliminating the need to convert to Unicode. In a...
osdn.net
name은 원하는 이름으로 설정
location은 위에 주소로 설정
한글이 깨지기 때문에 edit 프로그램을 실행한다.
name=" " : 키=값
<bundle01.jsp>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
teglib에 fmt를 설정해준다.
<%@ page language="java" 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>
<head>
<title>Internationalization</title>
</head>
<body>
<!-- value
1) 한글(ko) => message_ko.properties
2) 영어(en) => message_en.properties
-->
<fmt:setLocale value="ko"/>
<!-- bundle시작 -->
<fmt:bundle basename="resourceBundle.message">
<p><fmt:message key="name"/></p>
<p><fmt:message key="hello"/></p>
<!-- bundle 끝 -->
</fmt:bundle>
</body>
</html>
<fmt:setLocale/>과 <fmt:message>는 세트 같이 쓰자!
실행 시키면
file을 만들 때 _ko를 생략해도 됨 -> 기본이 ko로 설정되어있다.
<myBundle_en.properties>
title=Java Server Pages
username=admin
password=1234
<myBundle.properties>
title=Java Server Pages
username=admin
password=1234
<bundle02.jsp>
<%@ page language="java" 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>
<head>
<title>Internationalization</title>
</head>
<body>
<p>------기본(한글) 로케일-------</p>
<fmt:setLocale value="ko"/>
<fmt:bundle basename="bundle.myBundle">
<p>제목 : <fmt:message key="title" /></p>
<p>이름 : <fmt:message key="username" /></p>
</fmt:bundle>
<p>------영문 로케일-------</p>
<fmt:setLocale value="en"/>
<fmt:bundle basename="bundle.myBundle">
<p>제목 : <fmt:message key="title" /></p>
<p>이름 : <fmt:message key="username" /></p>
</fmt:bundle>
<hr />
<fmt:setBundle basename="bundle.myBundle" var="resourceBundle" />
<p>제목 : <fmt:message key="title" bundle="${resourceBundle}" /></p>
<fmt:message key="username" bundle="${resourceBundle}"
var="username" />
<p>이름 : ${username}</p>
</body>
</html>
'WEB > JSP' 카테고리의 다른 글
JSP 19 - 시큐리티(security) (0) | 2023.01.11 |
---|---|
JSP 18 - 쇼핑몰 사이트 만들기(6) [상품 등록 - (Bundle 사용)] (0) | 2023.01.11 |
JSP 16 - 쇼핑몰 사이트 만들기(5) [상품등록 - 정규식] (0) | 2023.01.10 |
JSP 15 - 정규표현식 (REGULAR EXPRESSION) (0) | 2023.01.09 |
JSP 15 - 유효성 검사 (Validation), 콜백함수,핸들러 함수, focus(),select() (0) | 2023.01.05 |
Comments