본문 바로가기
SPRING

230306_Tiles

by 경 훈 2023. 3. 6.

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<header>
<h1 align="center">
성적 관리 프로그램
</h1>
</header>
</header>
<nav class="navbar navbar-inverse">
	<div class="container-fluid">
	<div class="navbar-header">
		<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>                        
		</button>
	<a class="navbar-brand" href="/kim10_001/">HOME</a>
	</div>
	<div class="collapse navbar-collapse" id="myNavbar">
	<ul class="nav navbar-nav">
		<li class="active">
		</li>
		<li class="dropdown">
		<a class="dropdown-toggle" data-toggle="dropdown" href="#">성적관리<span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="in">입력</a></li>
				<li><a href="out">출력</a></li>
				<li><a href="lowout">총점이 200이하 자료출력</a></li>
				<li><a href="myin">마이입력</a></li>
				<li><a href="myout">마이출력</a></li>
				<li><a href="totout">전체출력(점수+정보)</a></li>
				<li><a href="totout3">번호,주소,이름,총점</a></li>
			</ul>
		</li>
		<li class="dropdown">
		<a class="dropdown-toggle" data-toggle="dropdown" href="#">오후예제<span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="cpin">컴퍼니입력</a></li>
				<li><a href="myinfoin">마이인포입력</a></li>
				<li><a href="cpout1">출력1</a></li>
				<li><a href="cpout2">출력2</a></li>
			</ul>
		</li>
	</ul>
	<ul class="nav navbar-nav navbar-right">
		<li><a href="mem"><span class="glyphicon glyphicon-user"></span>회원가입</a></li>
		<li><a href="login"><span class="glyphicon glyphicon-log-in"></span>로그인</a></li>
	</ul>
	</div>
	</div>
</nav>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">성적입력</h3>
	<form action="save" method="post">
		<table border="1" align="center">
			<tr>
				<th>번호</th>
				<td><input type="text" name="bun"></td>
			</tr>
			<tr>
				<th>이름</th>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<th>국어</th>
				<td><input type="text" name="kor"></td>
			</tr>
			<tr>
				<th>영어</th>
				<td><input type="text" name="eng"></td>
			</tr>
			<tr>
				<th>수학</th>
				<td><input type="text" name="mat"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="전송">
					<input type="reset" value="리셋">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">성적출력</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>번호</th><th>이름</th><th>국어</th>
			<th>영어</th><th>수학</th><th>총점</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].bun}</td><td>${list[i].name}</td><td>${list[i].kor}</td>
			<td>${list[i].eng}</td><td>${list[i].mat}</td><td>${list[i].tot}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">마이입력</h3>
	<form action="mysave" method="post">
		<table border="1" align="center">
			<tr>
				<th>번호</th>
				<td><input type="text" name="bun"></td>
			</tr>
			<tr>
				<th>전화번호</th>
				<td><input type="text" name="phone"></td>
			</tr>
			<tr>
				<th>주소</th>
				<td><input type="text" name="address"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="전송">
					<input type="reset" value="리셋">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">마이출력</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>번호</th><th>전화번호</th><th>주소</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].bun}</td><td>${list[i].phone}</td><td>${list[i].address}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">전체출력</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>번호</th><th>이름</th><th>국어</th>
			<th>영어</th><th>수학</th><th>총점</th>
			<th>전화번호</th><th>주소</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].bun}</td><td>${list[i].name}</td><td>${list[i].kor}</td>
			<td>${list[i].eng}</td><td>${list[i].mat}</td><td>${list[i].tot}</td>
			<td>${list[i].mydto.phone}</td><td>${list[i].mydto.address}</td>
		</tr>
		</c:forEach>
		<%-- <c:forEach items="${list}" var="list">
		<tr>
			<td>${list.bun}</td><td>${list.name}</td><td>${list.kor}</td>
			<td>${list.eng}</td><td>${list.mat}</td><td>${list.tot}</td>
			<td>${list.mydto.phone}</td><td>${list.mydto.address}</td>
		</tr>
		</c:forEach> --%>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">부분출력</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>번호</th><th>이름</th>
			<th>총점</th><th>주소</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].bun}</td><td>${list[i].name}</td>
			<td>${list[i].tot}</td><td>${list[i].mydto.address}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
	<definition name="baseLayout" template="/WEB-INF/views/layout.jsp">
		<put-attribute name="title" value=""/>
		<put-attribute name="top" value="/WEB-INF/views/top.jsp"/>
		<put-attribute name="body" value=""/>
		<put-attribute name="footer" value="/WEB-INF/views/footer.jsp"/>
	</definition>	   
	<definition name="main" extends="baseLayout">
		<put-attribute name="title" value="메인화면"/>
		<put-attribute name="body" value="/WEB-INF/views/main.jsp"/>
	</definition>  
	<definition name="input" extends="baseLayout">
		<put-attribute name="title" value="입력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/input.jsp"/>
	</definition>  
	<definition name="output" extends="baseLayout">
		<put-attribute name="title" value="출력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/output.jsp"/>
	</definition>  
	<definition name="myinput" extends="baseLayout">
		<put-attribute name="title" value="마이입력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/myinput.jsp"/>
	</definition>  
	<definition name="myoutput" extends="baseLayout">
		<put-attribute name="title" value="마이출력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/myoutput.jsp"/>
	</definition>  
	<definition name="totoutput" extends="baseLayout">
		<put-attribute name="title" value="전체출력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/totoutput.jsp"/>
	</definition>  
		<definition name="totoutput3" extends="baseLayout">
		<put-attribute name="title" value="전체출력폼3"/>
		<put-attribute name="body" value="/WEB-INF/views/totoutput3.jsp"/>
	</definition>  
	<definition name="companyinput" extends="baseLayout">
		<put-attribute name="title" value="컴퍼니입력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/companyinput.jsp"/>
	</definition>  
	<definition name="myinfoinput" extends="baseLayout">
		<put-attribute name="title" value="마이인포입력폼"/>
		<put-attribute name="body" value="/WEB-INF/views/myinfoinput.jsp"/>
	</definition>  
	<definition name="cpinfoout1" extends="baseLayout">
		<put-attribute name="title" value="cp출력1"/>
		<put-attribute name="body" value="/WEB-INF/views/cpinfoout1.jsp"/>
	</definition>  
	<definition name="cpinfoout2" extends="baseLayout">
		<put-attribute name="title" value="cp출력2"/>
		<put-attribute name="body" value="/WEB-INF/views/cpinfoout2.jsp"/>
	</definition>  
</tiles-definitions>

package com.ezen.kim10_001;

public class MyDTO {
	int bun;
	String phone,address;
	public MyDTO() {
	}
	public MyDTO(int bun, String phone, String address) {
		super();
		this.bun = bun;
		this.phone = phone;
		this.address = address;
	}
	public int getBun() {
		return bun;
	}
	public void setBun(int bun) {
		this.bun = bun;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
}

 

package com.ezen.kim10_001;

public class ScoreDTO {
	int bun;
	String name;
	int kor,eng,mat,tot;
	MyDTO mydto;
	public ScoreDTO() {
	}
	public ScoreDTO(int bun, String name, int kor, int eng, int mat, int tot) {
		super();
		this.bun = bun;
		this.name = name;
		this.kor = kor;
		this.eng = eng;
		this.mat = mat;
		this.tot = tot;
	}
	public int getBun() {
		return bun;
	}
	public void setBun(int bun) {
		this.bun = bun;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getKor() {
		return kor;
	}
	public void setKor(int kor) {
		this.kor = kor;
	}
	public int getEng() {
		return eng;
	}
	public void setEng(int eng) {
		this.eng = eng;
	}
	public int getMat() {
		return mat;
	}
	public void setMat(int mat) {
		this.mat = mat;
	}
	public int getTot() {
		return tot;
	}
	public void setTot(int tot) {
		this.tot = tot;
	}
	public MyDTO getMydto() {
		return mydto;
	}
	public void setMydto(MyDTO mydto) {
		this.mydto = mydto;
	}
}

 

package com.ezen.kim10_001;

import java.util.ArrayList;

public interface Service {
	public void insert(int bun,String name,int kor,int eng,int mat,int tot);
	public ArrayList<ScoreDTO> out();
	public ArrayList<ScoreDTO> lowout();
	public void myinsert(int bun,String phone,String address);
	public ArrayList<MyDTO> myout();
	public ArrayList<ScoreDTO> totout();
	public ArrayList<MyDTO> totout2();
	public ArrayList<ScoreDTO> totout3();
}

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ezen.kim10_001.Service">
	<insert id="insert">
		insert into score306 values (#{param1},#{param2},#{param3},#{param4},#{param5},#{param6})
	</insert>
	<resultMap type="com.ezen.kim10_001.MyDTO" id="my">
		<result property="bun" column="bun"/>
		<result property="phone" column="phone"/>
		<result property="address" column="address"/>
	</resultMap>
	<resultMap type="com.ezen.kim10_001.ScoreDTO" id="score">
		<result property="bun" column="bun"/>
		<result property="name" column="name"/>
		<result property="kor" column="kor"/>
		<result property="eng" column="eng"/>
		<result property="mat" column="mat"/>
		<result property="tot" column="tot"/>
		<collection property="mydto" resultMap="my"></collection>
	</resultMap>
	<select id="out" resultMap="score">
		select * from score306
	</select>
	<select id="lowout" resultMap="score">
	<![CDATA[
		select * from score306 where tot <= 200
		]]>
	</select>
	<insert id="myinsert">
		insert into my306 values (#{param1},#{param2},#{param3})
	</insert>
	<select id="myout" resultMap="my">
		select * from my306
	</select>
	<select id="totout" resultMap="score">
		select score306.bun,name,kor,eng,mat,tot,phone,address 
		from score306,my306 
		where score306.bun = my306.bun 
        group by score306.bun,name,kor,eng,mat,tot,phone,address 
        order by score306.bun asc
	</select>
<!-- 	<select id="totout" resultMap="score">
		select ss.bun,ss.name,ss.kor,ss.eng,ss.mat,ss.tot 
		from score306 ss, my306 my 
		where ss.bun = my.bun 
		group by ss.bun,ss.name,ss.kor,ss.eng,ss.mat,ss.tot 
		order by ss.bun asc
	</select>
	<select id="totout2" resultMap="my">
		select my.bun,my.phone,my.address 
		from score306 ss, my306 my 
		where ss.bun = my.bun 
		group by my.bun,my.phone,my.address 
        order by my.bun asc
	</select> -->
	<select id="totout3" resultMap="score">
		select score306.bun,tot,name,address 
		from score306,my306 
		where score306.bun = my306.bun 
        group by score306.bun,tot,name,address 
        order by score306.bun asc
	</select>
</mapper>

 

package com.ezen.kim10_001;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ezen.kim10_002.CompanyDTO;
import com.ezen.kim10_002.Service2;

@Controller
public class HomeController {
	@Autowired
	SqlSession sqlsession;
	@RequestMapping(value="/")
	public String ko1() {
		return "main";
	}
	@RequestMapping(value="/in")
	public String ko2() {
		return "input";
	}
	@RequestMapping(value="/save")
	public String ko3(HttpServletRequest request) {
		int bun=Integer.parseInt(request.getParameter("bun"));
		String name=request.getParameter("name");
		int kor=Integer.parseInt(request.getParameter("kor"));
		int eng=Integer.parseInt(request.getParameter("eng"));
		int mat=Integer.parseInt(request.getParameter("mat"));
		int tot = kor+eng+mat;
		Service1 ss = sqlsession.getMapper(Service1.class);
		ss.insert(bun,name,kor,eng,mat,tot);
		return "redirect:in";
	}
	@RequestMapping(value="/out")
	public String ko4(Model mo) {
		Service1 ss = sqlsession.getMapper(Service1.class);
		ArrayList<ScoreDTO> list = ss.out();
		mo.addAttribute("list", list);
		return "output";
	}
	@RequestMapping(value="/lowout")
	public String ko5(Model mo) {
		Service1 ss = sqlsession.getMapper(Service1.class);
		ArrayList<ScoreDTO> list = ss.lowout();
		mo.addAttribute("list", list);
		return "output";
	}
	@RequestMapping(value="/myin")
	public String ko6() {
		return "myinput";
	}
	@RequestMapping(value="/mysave")
	public String ko7(HttpServletRequest request) {
		int bun=Integer.parseInt(request.getParameter("bun"));
		String phone=request.getParameter("phone");
		String address=request.getParameter("address");
		Service1 ss = sqlsession.getMapper(Service1.class);
		ss.myinsert(bun, phone, address);
		return "redirect:myin";
	}
	@RequestMapping(value="/myout")
	public String ko8(Model mo) {
		Service1 ss = sqlsession.getMapper(Service1.class);
		ArrayList<MyDTO> list = ss.myout();
		mo.addAttribute("list", list);
		return "myoutput";
	}
	@RequestMapping(value="/totout")
	public String ko9(Model mo) {
		Service1 ss = sqlsession.getMapper(Service1.class);
		ArrayList<ScoreDTO> list = ss.totout();
//		ArrayList<MyDTO> list2 = ss.totout2();
		mo.addAttribute("list", list);
//		mo.addAttribute("list2", list2);
		return "totoutput";
	}
	@RequestMapping(value="/totout3")
	public String ko10(Model mo) {
		Service1 ss = sqlsession.getMapper(Service1.class);
		ArrayList<ScoreDTO> list = ss.totout3();
		mo.addAttribute("list", list);
		return "totoutput3";
	}
	@RequestMapping(value="/cpin")
	public String ko11() {
		return "companyinput";
	}
	@RequestMapping(value="/myinfoin")
	public String ko12() {
		return "myinfoinput";
	}
	@RequestMapping(value="/companysave")
	public String ko13(HttpServletRequest request) {
		int num=Integer.parseInt(request.getParameter("num"));
		String name=request.getParameter("name");
		int pay=Integer.parseInt(request.getParameter("pay"));
		Service2 ss = sqlsession.getMapper(Service2.class);
		ss.cpinsert(num,name,pay);
		return "redirect:cpin";
	}
	@RequestMapping(value="/myinfosave")
	public String ko14(HttpServletRequest request) {
		int num=Integer.parseInt(request.getParameter("num"));
		String gender=request.getParameter("gender");
		String phone=request.getParameter("phone");
		int age=Integer.parseInt(request.getParameter("age"));
		Service2 ss = sqlsession.getMapper(Service2.class);
		ss.myinfoinsert(num, gender, phone, age);
		return "redirect:myinfoin";
	}
	@RequestMapping(value="/cpout1")
	public String ko15(Model mo) {
		Service2 ss = sqlsession.getMapper(Service2.class);
		ArrayList<CompanyDTO> list = ss.cpout1();
		mo.addAttribute("list", list);
		return "cpinfoout1";
	}
	@RequestMapping(value="/cpout2")
	public String ko16(Model mo) {
		Service2 ss = sqlsession.getMapper(Service2.class);
		ArrayList<CompanyDTO> list = ss.cpout2();
		mo.addAttribute("list", list);
		return "cpinfoout2";
	}
}

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">마이인포입력</h3>
	<form action="myinfosave" method="post">
		<table border="1" align="center">
			<tr>
				<th>사원번호</th>
				<td><input type="text" name="num"></td>
			</tr>
			<tr>
				<th>성별</th>
				<td>
					<input type="radio" name="gender" value="남자">남자
					<input type="radio" name="gender" value="여자">여자
				</td>
			</tr>
			<tr>
				<th>전화번호</th>
				<td><input type="text" name="phone"></td>
			</tr>
			<tr>
				<th>나이</th>
				<td><input type="text" name="age"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="전송">
					<input type="reset" value="리셋">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">컴퍼니입력</h3>
	<form action="companysave" method="post">
		<table border="1" align="center">
			<tr>
				<th>사원번호</th>
				<td><input type="text" name="num"></td>
			</tr>
			<tr>
				<th>이름</th>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<th>급여</th>
				<td><input type="text" name="pay"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<input type="submit" value="전송">
					<input type="reset" value="리셋">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">cp출력1</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>사원번호</th><th>이름</th><th>급여</th>
			<th>성별</th><th>전화번호</th><th>나이</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].num}</td><td>${list[i].name}</td>
			<td>
			<fmt:formatNumber value="${list[i].pay}" pattern="#,##0"></fmt:formatNumber>
			</td>
			<td>${list[i].myinfodto.gender}</td><td>${list[i].myinfodto.phone}</td><td>${list[i].myinfodto.age}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3 align="center">cp출력2</h3>
	<table border="1" align="center" width="600px">
		<tr>
			<th>사원번호</th><th>이름</th><th>급여</th>
			<th>나이</th>
		</tr>
		<c:forEach var="i" begin="0" end="${fn:length(list)-1}" step="1">
		<tr>
			<td>${list[i].num}</td><td>${list[i].name}</td>
			<td>
			<fmt:formatNumber value="${list[i].pay}" pattern="#,##0"></fmt:formatNumber>
			</td>
			<td>${list[i].myinfodto.age}</td>
		</tr>
		</c:forEach>
	</table>
</body>
</html>

package com.ezen.kim10_002;

public class MyinfoDTO {
	int num;
	String gender,phone;
	int age;
	public MyinfoDTO() {
	}
	public MyinfoDTO(int num, String gender, String phone, int age) {
		super();
		this.num = num;
		this.gender = gender;
		this.phone = phone;
		this.age = age;
	}
	public int getNum() {
		return num;
	}
	public void setNum(int num) {
		this.num = num;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
}

 

package com.ezen.kim10_002;

public class CompanyDTO {
	int num;
	String name;
	int pay;
	MyinfoDTO myinfodto;
	public CompanyDTO() {
	}
	public CompanyDTO(int num, String name, int pay) {
		super();
		this.num = num;
		this.name = name;
		this.pay = pay;
	}
	public int getNum() {
		return num;
	}
	public void setNum(int num) {
		this.num = num;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getPay() {
		return pay;
	}
	public void setPay(int pay) {
		this.pay = pay;
	}
	public MyinfoDTO getMyinfodto() {
		return myinfodto;
	}
	public void setMyinfodto(MyinfoDTO myinfodto) {
		this.myinfodto = myinfodto;
	}
}

 

package com.ezen.kim10_002;

import java.util.ArrayList;

public interface Service2 {
	public void cpinsert(int num,String name,int pay);
	public void myinfoinsert(int num,String gender,String phone,int age);
	public ArrayList<CompanyDTO> cpout1();
	public ArrayList<CompanyDTO> cpout2();
}

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.ezen.kim10_002.Service2">
	<insert id="cpinsert">
		insert into db03061 values (#{param1},#{param2},#{param3})
	</insert>
	<insert id="myinfoinsert">
		insert into db03062 values (#{param1},#{param2},#{param3},#{param4})
	</insert>
	<resultMap type="com.ezen.kim10_002.MyinfoDTO" id="myinfo">
		<result property="num" column="num"/>
		<result property="gender" column="gender"/>
		<result property="phone" column="phone"/>
		<result property="age" column="age"/>
	</resultMap>
	<resultMap type="com.ezen.kim10_002.CompanyDTO" id="cp">
		<result property="num" column="num"/>
		<result property="name" column="name"/>
		<result property="pay" column="pay"/>
		<collection property="myinfodto" resultMap="myinfo"></collection>
	</resultMap>
	<select id="cpout1" resultMap="cp">
		select db03061.num,name,pay,gender,phone,age 
		from db03061,db03062 
		where db03061.num = db03062.num 
		group by db03061.num,name,pay,gender,phone,age 
		order by db03061.num asc
	</select>
	<select id="cpout2" resultMap="cp">
		select db03061.num,name,pay,age 
		from db03061,db03062 
		where db03061.num = db03062.num 
		group by db03061.num,name,pay,age 
		order by db03061.num asc
	</select>
</mapper>

 

'SPRING' 카테고리의 다른 글

230308_AJAX  (0) 2023.03.08
230307_Tiles  (0) 2023.03.07
230303_Tiles  (0) 2023.03.03
230302_Tiles  (0) 2023.03.02
230228_Tiles  (0) 2023.02.28

댓글