받는jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.Enumeration"%>
<%
request.setCharacterEncoding("UTF-8");
// Enumeration열거형
Enumeration en = request.getParameterNames();
while(en.hasMoreElements()){
String name = (String)en.nextElement();
String value = request.getParameter(name);
out.print("<h5>"+name+":"+value+"</h5>");
}
%>
예시
addProduct.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="kr.or.ddit.vo.ProductVO"%>
<%@page import="kr.or.ddit.dao.ProductRepository"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/bootstrap.min.css" />
<title></title>
</head>
<body>
<!-- include 액션태그 -->
<jsp:include page="menu.jsp"/>
<div class="jumbotron">
<!-- container : 이 안에 내용있다 -->
<div class="container">
<h1 class="display-3">상품 등록</h1>
</div>
</div>
<div class="container">
<!-- 폼태그, 폼페이지 -->
<form name = "newProduct" action="processAddProduct.jsp" method="post"
class = "form-horizontal">
<div class = "form-group row">
<!-- 후보키(N.N, N.D) -> 중 1 속성 선택 -> 기본키(N.N,N.D) -->
<label class = "col-sm-2">상품 아이디 </label>
<input type ="text" id="productId" name = "productId"
class = "form-controler" placeholder="상품아이디" required>
</div>
<div class = "form-group row">
<label class = "col-sm-2">상품 명 </label>
<input type ="text" id="pname" name = "pname"
class = "form-controler" placeholder="상품명" required>
</div>
<div class = "form-group row">
<label class = "col-sm-2">상품 가격 </label>
<input type ="number" id="unitPrice" name = "unitPrice"
class = "form-controler" placeholder="상품가격" required>
</div>
<div class = "form-group row">
<label class = "col-sm-2">상품 설명 </label>
<input type ="text" id="description" name = "description"
class = "form-controler" placeholder="상품설명" >
</div>
<div class = "form-group row">
<label class = "col-sm-2">제조사 </label>
<input type ="text" id="manufacturer" name = "manufacturer"
class = "form-controler" placeholder="제조사">
</div>
<div class = "form-group row">
<label class = "col-sm-2">분류 </label>
<input type ="text" id="category" name = "category"
class = "form-controler" placeholder="분류">
</div>
<div class = "form-group row">
<label class = "col-sm-2">재고 수 </label>
<input type ="text" id="unitsInStock" name = "unitsInStock"
class = "form-controler" placeholder="재고 수">
</div>
<div class = "form-group row">
<label class = "col-sm-2">제품 상태</label>
<div class = "col-sm-5">
<input type = "radio" name = "condition" value="New"/>신상품
<input type = "radio" name = "condition" value="Old"/>중고
<input type = "radio" name = "condition" value="Refurbished"/>재생품
</div>
</div>
<div class ="form-group row">
<div class = "col-sm-offset-2 col-sm-10">
<input type="submit" class = "btn btn-primary" value="등록"/>
<button type="button" class= "btn btn-info" onclick="javascripe:location.href='products.jsp'">목록보기</button>
</div>
</div>
</form>
</div>
<jsp:include page="footer.jsp"/>
</body>
</html>
processAddProduct.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.Enumeration"%>
<%
request.setCharacterEncoding("UTF-8");
// Enumeration열거형
Enumeration en = request.getParameterNames();
while(en.hasMoreElements()){
String name = (String)en.nextElement();
String value = request.getParameter(name);
out.print("<h5>"+name+":"+value+"</h5>");
}
%>
'JAVA > JSP' 카테고리의 다른 글
Cookie (1) | 2024.04.20 |
---|---|
Common-FileUpload (vo 없는 버전) (0) | 2024.04.09 |
내장객체 (0) | 2024.04.05 |
디렉티브 태그 (0) | 2024.04.05 |
jsp 방문수 횟수 늘리기 (0) | 2024.04.05 |