728x90
아스키 코드로 안써지고 한글로 써진다면
<fmt:setLocale value="ko"/>
<fmt:setLocale value="en"/>
둘중 하나 쓰겠다.
<fmt:bundle basename="bundle.message">여기에 묶일 코드</fmt:bundle>
bundle : bundle패키지 명
message : message.property 파일명
전체코드
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<!-- 링크 렐르 흐 -->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<title>상품 등록</title>
<!-- WYSIWYG(What You See Is What You Get) -->
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/js/jquery-3.6.0.js"></script>
<script type="text/javascript" src="/js/validation.js"></script>
<script>
//document 내 요소 모두 로딩 후 처리
$(function(){
console.log("개똥이");
//이미지 미리보기 시작
$("#productImage").on("change", handleImg);
//e : change event
function handleImg(e){
//첨부파일들
let files = e.target.files;
//파일 배열 Object
let fileArr = Array.prototype.slice.call(files);
//파일 반복
fileArr.forEach(function(f){
if(!f.type.match("image.*")){
alert("이미지 확장자만 가능합니다.");
//함수 종료
return;
}
let reader = new FileReader();
//e : 파일 읽을 때 이벤트
reader.onload = function(e){
let img_html = "<img src='"+e.target.result + "'style='width:100%;'/>";
//class = col-sm-5 divImg
$('.divImg').html(img_html);
}
//리더로 파일 읽음
reader.readAsDataURL(f);
});
}
});
</script>
</head>
<body>
<!-- /addProduct.jsp?language=en -->
<%-- <fmt:setLocale value='<%=request.getParameter("language") %>'/> --%>
<fmt:setLocale value="${param.language}" />
<!--
bundle : bundle패키지 명
message : message.property 파일명
-->
<fmt:bundle basename="bundle.message">
<!-- header.jsp -->
<jsp:include page="menu.jsp" />
<!-- 상품 등록 시작 -->
<div class= "jumbotron">
<!-- container : 이 안에 내용있다. -->
<div class="container">
<h1 class="display-3"><fmt:message key="title" /></h1>
</div>
</div>
<!-- 상품 등록 폼 필드 시작 -->
<div class="container">
<div class="text-right">
<!-- ?language=ko => addProduct.jsp?language=ko -->
<a href="?language=ko">Korean</a> <a href="?language=en">English</a>
</div>
<!-- 폼필드
요청 URL : processAddProduct.jsp
요청방식 : post
요청파라미터(HTTP파라미터,QueryString)
{productId=P1237, pname=에어팟3,unitPrice=200000,description=굿음질
manufacturer = Apple,category=Table, unitsInStock=1000, condition=Old,
}
-->
<form name="newProduct" action="processAddProduct.jsp"
class="form-horizontal" method="post" enctype="multipart/form-data">
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="productId" /></label>
<div class="col-sm-3">
<input type="text" name="productId"
class="form-control" required />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="pname" /></label>
<div class="col-sm-3">
<input type="text" name="pname"
class="form-control" required />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="unitPrice" /></label>
<div class="col-sm-3">
<input type="number" name="unitPrice"
class="form-control" required />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="description" /></label>
<div class="col-sm-3">
<textarea name="description" rows="3" cols="50"
class="form-control" ></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="manufacturer" /></label>
<div class="col-sm-3">
<input type="text" name="manufacturer"
class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="category" /></label>
<div class="col-sm-3">
<input type="text" name="category"
class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="unitsInStock" /> </label>
<div class="col-sm-3">
<input type="number" name="unitsInStock"
class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="condition" /></label>
<div class="col-sm-5">
<input type="radio" id="condition1" name="condition" value="New" />
<label for="condition1"><fmt:message key="condition_New" /></label>
<input type="radio" id="condition2" name="condition" value="Old"/>
<label for="condition2"><fmt:message key="condition_Old" /></label>
<input type="radio" id="condition3" name="condition" value="Refurbished"/>
<label for="condition3"><fmt:message key="condition_Refurbished" /></label>
</div>
</div>
<!-- 상품 이미지 -->
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="productImage" /></label>
<div class="col-sm-5">
<input type="file" id="productImage" name="productImage" class="form-control" />
</div>
</div>
<!-- 상품 이미지 미리보기 -->
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="productPreImage" /></label>
<div class="col-sm-5 divImg"></div>
</div>
<div class="form-group row">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" class="btn btn-primary" value="<fmt:message key="button" />"
onclick="CheckAddProduct()"/>
</div>
</div>
</form>
</div>
<!-- 상품 등록 폼 필드 끝-->
<!-- footer.jsp -->
<jsp:include page="footer.jsp" />
</fmt:bundle>
<script>
CKEDITOR.replace("description");
</script>
</body>
</html>
'JSP > JSP기초' 카테고리의 다른 글
JSP(security) 선언적 시큐리티 처리 방법_FORM (0) | 2023.07.07 |
---|---|
JSP(security) 선언적 시큐리티 처리 방법_BASIC (0) | 2023.07.07 |
[Javascript]다국어처리 국제화 (0) | 2023.07.07 |
JSP(validation) 정규식표현 정리 (0) | 2023.07.06 |
include 사용방법 (0) | 2023.06.23 |