티스토리 뷰

 

Domain

Hospital.java

package com.springmvc.domain;

import java.io.Serializable;

import org.springframework.web.multipart.MultipartFile;

public class Hospital implements Serializable{

	
	private static final long serialVersionUID = -5462014620475570954L;

	
	private String hospitalId;  //병원ID
	private String hospitalName;  //병원이름
	private String hospitalPlace;  //병원위치
	private String hospitalNumber;  //병원전화번호
	private String hospitalReview;  //병원리뷰번호
	private String hospitalSubject;  //병원진료과목
	private MultipartFile hospitalImage;  //이미지
	private String fileName;  //파일이름
	
	public Hospital() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	public String getHospitalName() {
		return hospitalName;
	}

	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}

	public String getHospitalPlace() {
		return hospitalPlace;
	}

	public void setHospitalPlace(String hospitalPlace) {
		this.hospitalPlace = hospitalPlace;
	}

	public String getHospitalNumber() {
		return hospitalNumber;
	}

	public void setHospitalNumber(String hospitalNumber) {
		this.hospitalNumber = hospitalNumber;
	}

	public String getHospitalReview() {
		return hospitalReview;
	}

	public void setHospitalReview(String hospitalReview) {
		this.hospitalReview = hospitalReview;
	}

	public MultipartFile getHospitalImage() {
		return hospitalImage;
	}

	public void setHospitalImage(MultipartFile hospitalImage) {
		this.hospitalImage = hospitalImage;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getHospitalSubject() {
		return hospitalSubject;
	}

	public void setHospitalSubject(String hospitalSubject) {
		this.hospitalSubject = hospitalSubject;
	}
	
	
}

 

 

 

 

 


controller

 

HospitalController.java

package com.springmvc.controller;

import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.springmvc.domain.Hospital;
import com.springmvc.service.HospitalService;

@Controller
@RequestMapping("/hospital")
public class HospitalController {
	
	@Autowired
	private HospitalService hospitalService;
	
	
	@GetMapping
	public String requestHospitalList(Model model) {
		List<Hospital> list = hospitalService.readAllHospitalList();
		model.addAttribute("hospitalList",list);
		return "hospitals";
	}
	
	@GetMapping("/all")
	public String requestAllHospitals(@RequestParam("id") String hospitalId, Model model) {
		List<Hospital> list = hospitalService.readAllHospitalList();
		model.addAttribute("hospitalList", list);
		
		return "hospitals";
	}
	
	@GetMapping("/hospital")
	public String requestHospitalById(@RequestParam("id") String hospitalId, Model model) {
		Hospital hospitalById = hospitalService.readHospitalById(hospitalId);
		model.addAttribute("hospital", hospitalById);
		
		return "hospital";
	}
	
	
	//Create
	@GetMapping("/add")
	public String requestAddHospitalForm(@ModelAttribute("addHospital")Hospital hospital) {
		return "hadd";  //병원등록페이지.jsp
	}
	
	@PostMapping("/add")
	public String submitAddNewHospital(@ModelAttribute("addHospital")Hospital hospital, HttpServletRequest request) {
		
		MultipartFile img = hospital.getHospitalImage();
		
		String saveName = img.getOriginalFilename();
		String save = request.getSession().getServletContext().getRealPath("/resources/images");
		File saveFile = new File(save,saveName);
		
		if(img!=null&&!img.isEmpty()) 
		{
			try 
			{
				img.transferTo(saveFile);
				hospital.setFileName(saveName);
			} 
			
			catch (Exception e) 
			{
				throw new RuntimeException("병원 이미지 업로드 실패");
			}
			
		}
		
		hospitalService.setNewHospital(hospital);
		return "redirect:/hospitals";
		
	}
	
	
	@GetMapping("/update")
	public String getUpdateHospitalForm(@ModelAttribute("updateHospital") Hospital hospital, @RequestParam("id") String hospitalId, Model model) {
		Hospital hospitalById = hospitalService.readHospitalById(hospitalId);
		model.addAttribute("hospital",hospitalById);
		return "hupdateForm";  //업데이트하는jsp호출함
	}
	
	@PostMapping("/update")
	public String submitUpdateHospitalForm(@ModelAttribute("updateHospital") Hospital hospital, HttpServletRequest request) {
		MultipartFile img = hospital.getHospitalImage();
		
		String saveName = img.getOriginalFilename();
		String save = request.getSession().getServletContext().getRealPath("/resources/images");
		
		File saveFile = new File(save,saveName);
		
		if(img!=null&&!img.isEmpty()) 
		{
			try 
			{
				img.transferTo(saveFile);
				hospital.setFileName(saveName);
			}
			
			catch (Exception e) 
			{
				throw new RuntimeException("이미지 업로드 실패");
			}
		}
		hospitalService.setUpdateHospital(hospital);
		return "redirect:/hospitals";
	}
	
	@GetMapping(value="/delete")
	public String getDeleteForm(Model model, @RequestParam("id") String hospitalId) {
		hospitalService.setDeleteHospital(hospitalId);
		return "redirect:/hospitals";
	}
	

}

 

 

 

 

 

 

 


repository

 

HospitalRepository.interface

package com.springmvc.repository;

import java.util.List;

import com.springmvc.domain.Hospital;

public interface HospitalRepository {
	
	List<Hospital> readAllHospitalList();
	List<Hospital> readHospitalListBySubject(String hospitalSubject);
	Hospital readHospitalById(String hospitalId);
	void setNewHospital(Hospital hospital);
	void setUpdateHospital(Hospital hospital);
	void setDeleteHospital(String hospitalId);

}

 

 

HospitalRepositoryImpl.java

package com.springmvc.repository;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.springmvc.domain.Hospital;


@Repository
public class HospitalRepositoryImpl implements HospitalRepository{

	private JdbcTemplate template;
	
	@Autowired
	public void setJdbcTemplate(DataSource dataSource) {
		this.template = new JdbcTemplate(dataSource);
	}
	
	
	@Override
	public List<Hospital> readAllHospitalList() {
		String SQL = "SELECT * FROM hospital";
		List<Hospital> listOfHospitals = template.query(SQL, new HospitalRowMapper());
		return listOfHospitals;
	}

	@Override
	public List<Hospital> readHospitalListBySubject(String hospitalSubject) {

		List<Hospital> hospitalBySubject = new ArrayList<Hospital>();
		
		String SQL = "SELECT * FROM hospital WHERE h_subject LIKE '%"+hospitalSubject+"%'";
		hospitalBySubject = template.query(SQL, new HospitalRowMapper());
		return hospitalBySubject;
	}

	@Override
	public Hospital readHospitalById(String hospitalId) {
		Hospital hospitalInfo = null;
		
		String SQL = "SELECT COUNT(*) FROM hospital WHERE h_id=?";
		int rowCount = template.queryForObject(SQL, Integer.class, hospitalId);
		
		if(rowCount!=0) {
			SQL="SELECT * FROM hospital WHERE h_id=?";
			hospitalInfo = template.queryForObject(SQL, new Object[] {hospitalId}, new HospitalRowMapper());
		}
		if(hospitalInfo == null) {
			throw new IllegalArgumentException("일치하는 병원을 찾을 수 없습니다.");
		}
		return hospitalInfo;
	}

	
	@Override
	public void setNewHospital(Hospital hospital) {
		
		String SQL = "INSERT INTO hospital (h_id,h_name,h_place,h_number,h_reviewnumber,h_subject,h_filename)"+"VALUES(?,?,?,?,?,?,?)";
		template.update(SQL,hospital.getHospitalId(),hospital.getHospitalName(),hospital.getHospitalPlace(),hospital.getHospitalNumber(),hospital.getHospitalReview(),hospital.getHospitalSubject(),hospital.getFileName());
		
	}

	
	@Override
	public void setUpdateHospital(Hospital hospital) {
		
		if(hospital.getFileName()!=null) {
			String SQL = "UPDATE hospital SET h_name=?,h_place=?,h_number=?,h_reviewnumber=?,h_subject=?,h_filename=? WHERE h_id=?";
			template.update(SQL,hospital.getHospitalName(),hospital.getHospitalPlace(),hospital.getHospitalNumber(),hospital.getHospitalReview(),hospital.getHospitalSubject(),hospital.getFileName(),hospital.getHospitalId());
		}
		else if(hospital.getFileName()==null) 
		{
			String SQL = "UPDATE hospital SET h_name=?,h_place=?,h_number=?,h_reviewnumber=?,h_subject=? WHERE h_id=?";
			template.update(SQL,hospital.getHospitalName(),hospital.getHospitalPlace(),hospital.getHospitalNumber(),hospital.getHospitalReview(),hospital.getHospitalSubject(),hospital.getHospitalId());
		
		}
		
	}

	
	@Override
	public void setDeleteHospital(String hospitalId) {
		String SQL = "DELETE FROM hospital WHERE h_id=?";
		this.template.update(SQL,hospitalId);
		
	}
	

	public void setTemplate(JdbcTemplate template) {
		this.template = template;
	}

}

 

 

 

HospitalRowMapper.java

package com.springmvc.repository;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.springmvc.domain.Hospital;

public class HospitalRowMapper implements RowMapper<Hospital>{

	public Hospital mapRow(ResultSet rs, int rowNum) throws SQLException{
		Hospital hospital = new Hospital();
		hospital.setHospitalId(rs.getString(1));
		hospital.setHospitalName(rs.getString(2));
		hospital.setHospitalPlace(rs.getString(3));
		hospital.setHospitalNumber(rs.getString(4));
		hospital.setHospitalReview(rs.getString(5));
		hospital.setHospitalSubject(rs.getString(6));
		hospital.setFileName(rs.getString(7));
		
		return hospital;
	}
}

 

 

 

 

 

 


service

 

HospitalService.interface

package com.springmvc.service;

import java.util.List;

import com.springmvc.domain.Hospital;

public interface HospitalService {

	List<Hospital> readAllHospitalList();
	List<Hospital> readHospitalListBySubject(String hospitalSubject);
	Hospital readHospitalById(String hospitalId);
	void setNewHospital(Hospital hospital);
	
	void setUpdateHospital(Hospital hospital);
	void setDeleteHospital(String hospitalId);
}

 

 

HospitalServiceImpl.java

package com.springmvc.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.springmvc.domain.Hospital;
import com.springmvc.repository.HospitalRepository;

@Service
public class HospitalServiceImpl implements HospitalService{
	
	@Autowired
	private HospitalRepository hospitalRepository;

	
	@Override
	public List<Hospital> readAllHospitalList() {
		// TODO Auto-generated method stub
		return hospitalRepository.readAllHospitalList();
	}

	@Override
	public List<Hospital> readHospitalListBySubject(String hospitalSubject) {

		List<Hospital> hospitalBySubject =  hospitalRepository.readHospitalListBySubject(hospitalSubject);
		
		return hospitalBySubject;
	}

	@Override
	public Hospital readHospitalById(String hospitalId) {
		Hospital hospitalById = hospitalRepository.readHospitalById(hospitalId);
		return hospitalById;
	}

	@Override
	public void setNewHospital(Hospital hospital) {
		hospitalRepository.setNewHospital(hospital);
		
	}

	@Override
	public void setUpdateHospital(Hospital hospital) {
		hospitalRepository.setUpdateHospital(hospital);
		
	}

	@Override
	public void setDeleteHospital(String hospitalId) {
		hospitalRepository.setDeleteHospital(hospitalId);
		
	}

}

 

 


sql

drop table hospital;
CREATE TABLE IF NOT EXISTS hospital(
	h_id varchar(20) NOT NULL PRIMARY KEY,
    h_name varchar(20) NOT NULL,
    h_place varchar(50) NOT NULL,
    h_number varchar(20),
    h_reviewnumber varchar(20),
    h_subject varchar(50),
    h_filename varchar(30)
    )default charset=utf8;
    
select * from hospital;

insert into hospital values('H55','행복정형외과','창원시 마산 회원구','055-123-4444',null,'서울특별시',null);

 

 

 

 

 


 

병원목록 조회

 

hospitals.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!-- form 사용을 위한 선언 -->
    
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="<c:url value="/resources/css/bootstrap.min.css"/>"rel="stylesheet" />
<script src="${pageContext.request.contextPath }/resources/js/controllers.js"></script>
<!-- 스크립트 사용을 위해 선언 -->
<title>병원 정보</title>
</head>
<body>
<h2>병원 목록</h2>

<c:forEach var="hospital" items="${hospitalList}">
    <div>
		<c:choose>
			<c:when test="${hospital.getHospitalImage() == null}">
				<img src="<c:url value='/resources/images/${hospital.fileName}'/>" style="width: 50%"/>
			</c:when>
			<c:otherwise>
				<img src="<c:url value='/resources/images/${hospital.fileName}'/>" style="width: 50%"/>
			</c:otherwise>
		</c:choose>
	</div>
    <div>
        <p>병원 ID: ${hospital.hospitalId}</p>
        <p>병원 이름: ${hospital.hospitalName}</p>
        <p>위치 : ${hospital.hospitalPlace}</p>
		<p>번호 : ${hospital.hospitalNumber}</p>
		<p>진료과목 : ${hospital.hospitalSubject}</p>		
		<p><a href="<c:url value="/hospital/hospital?id=${hospital.hospitalId}"/>"class="btn btn-secondary" role="button">상세정보 &raquo;</a>
	    </div>
	    <hr>
</c:forEach>
</body>
</html>

 

 

 

 

 

 

 


병원 상세정보 

 

hospital.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2>병원 정보</h2>

<c:if test="${not empty hospital}">
	<div class="col-md-4">
		<c:choose>
			<c:when test="${hospital.getHospitalImage() == null}">
				<img src="<c:url value='/resources/images/${hospital.fileName}'/>" style="width: 50%"/>
			</c:when>
			<c:otherwise>
				<img src="<c:url value='/resources/images/${hospital.fileName}'/>" style="width: 50%"/>
			</c:otherwise>
		</c:choose>
	</div>
    <div>
        <p>병원 ID: ${hospital.hospitalId}</p>
        <p>병원 이름: ${hospital.hospitalName}</p>
        <p>위치 : ${hospital.hospitalPlace }</p>
        <p>전화번호 : ${hospital.hospitalNumber }</p>
		<form:form name="addForm" method="put">        	
		    <a href='<c:url value="/hospital/update?id=${hospital.hospitalId}"/>' class="btn btn-success">수정&raquo;</a>
		    <a href="<c:url value='/hospital/delete?id=${hospital.hospitalId}'/>" class="btn btn-danger" onclick="return deleteConfirm('${hospital.hospitalId}')">삭제 &raquo;</a>
		    <a href="<c:url value='/hospital/review?id=${hospital.hospitalId}'/>" class="btn btn-success">리뷰&raquo;</a>
		    
		</form:form>
    </div>
    <hr>
</c:if>
</body>
</html>

 

 

 

 

 

 

 

 

 

병원등록

 

hadd.jsp

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>     
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>      
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="<c:url value="/resources/css/bootstrap.min.css"/>"rel="stylesheet" />
<title>병원 등록</title>
</head>
<body>
	<nav class="navbar navbar-expand navbar-dark bg-dark">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand" href="./home">Home</a>
			</div>
		</div>
	</nav>
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">병원 등록</h1>
		</div>
	</div>
	
	<div class="container">
		<form:form modelAttribute="addHospital" enctype="multipart/form-data" class="form-horizontal">
		<fieldset>
			<div class="form-group row">
				<label class="col-sm-2 control-label">병원ID</label>
				<div class="col-sm-3">
					<form:input path="hospitalId" class="form-control" />
				</div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 control-label">병원명</label>
				<div class="col-sm-3">
					<form:input path="hospitalName" class="form-control" />
				</div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 control-label">위치</label>
				<div class="col-sm-3">
					<form:input path="hospitalPlace" class="form-control" />
				</div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 control-label">병원번호</label>
				<div class="col-sm-3">
					<form:input path="hospitalNumber" class="form-control" />
				</div>
			</div>
			<div class="form-group row">
			    <label class="col-sm-2 control-label">진료과목</label>
			    <div class="col-sm-3">
			        <form:checkbox path="hospitalSubject" value="정형외과" class="form-control" />서울특별시
			        <form:checkbox path="hospitalSubject" value="내과" class="form-control" />인천광역시
			        <form:checkbox path="hospitalSubject" value="외과" class="form-control" />경상남도
			    </div>
			</div>
			<div class="form-group row">
				<label class="col-sm-2 control-label">병원사진</label>
				<div class="col-sm-7">
					<form:input path="hospitalImage" type="file" class="form-control" />
				</div>
			</div>
			<div class="form-group row">
				<div class="col-sm-offset-2 col-sm-10">
				<input type="submit" class="btn btn-primary" value="등록하기" />
				<input type="reset" class="btn btn-primary" value="다시쓰기" />
				</div>
			</div>
		</fieldset>
		</form:form>
		<hr>
	<footer>
		<p>&copy; hospital</p>
	</footer>	
	</div>
</body>
</html>

 

 

 

 

 

 

 

 

 

 

 

 


병원 정보 수정

 

hupdateForm.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div class="container">
<h3>병원 수정 페이지</h3>
	<div class="col-md-4">
		<img src="<c:url value='/resources/images/${hospital.fileName}'/>" alt="image" style="width: 50%"/>
	</div>
	<form:form modelAttribute="updateHospital" action="./update?id=${hospital.hospitalId}" class="form-horizontal" enctype="multipart/form-data">
		<p> 병원 아이디 : <form:input path="hospitalId" value="${hospital.hospitalId}"/> <!-- path 는 DTO 객체의 변수 -->
		<p> 병원 이름 : <form:input path="hospitalName" value="${hospital.hospitalName}"/>
		<p> 위치 : <form:input path="hospitalPlace" value="${hospital.hospitalPlace}"/>
		<p> 전화번호 : <form:input path="hospitalNumber" value="${hospital.hospitalNumber}"/>
		<p> 진료과목 : <form:input path="hospitalSubject" value="${hospital.hospitalSubject}"/>
		<div class="col-sm-10">
			이미지<form:input path="hospitalImage" type="file" class="form-control"/>
		</div>
		<div class="form-group row">
			<input type="submit" class="btn btn-primary" value="수정"/>
			<a href="<c:url value="/hospitals"/>" class="btn btn-primary">취소</a>
		</div>
	</form:form>
</div>
</body>
</html>

 

 

 

 

수정 후

 

 

 

 

 

 


병원 삭제

 

 

 

 

 

 

 

 

 

 

 

 


pom.xml

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.springmvc</groupId>
  <artifactId>waguwagu</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>waguwagu Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
      <java-version>17</java-version>
      <org.springframework-version>5.3.19</org.springframework-version>
      <org.aspectj-version>1.6.10</org.aspectj-version>
      <org.slf4j-version>1.6.6</org.slf4j-version>
      <security.version>5.6.3</security.version>
      <commons-fileupload-version>1.4</commons-fileupload-version>
      <commons-io-version>2.11.0</commons-io-version>
      <org.apache.tiles-version>3.0.8</org.apache.tiles-version>
  </properties>
  

   <dependencies>
      <!-- Spring -->
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
         <version>${org.springframework-version}</version>
         <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
               <groupId>commons-logging</groupId>
               <artifactId>commons-logging</artifactId>
             </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-webmvc</artifactId>
         <version>${org.springframework-version}</version>
      </dependency>
            
      <!-- AspectJ -->
      <dependency>
         <groupId>org.aspectj</groupId>
         <artifactId>aspectjrt</artifactId>
         <version>${org.aspectj-version}</version>
      </dependency>   
      
      <!-- Logging -->
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>${org.slf4j-version}</version>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>jcl-over-slf4j</artifactId>
         <version>${org.slf4j-version}</version>
         <scope>runtime</scope>
      </dependency>
      <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-log4j12</artifactId>
         <version>${org.slf4j-version}</version>
         <scope>runtime</scope>
      </dependency>
      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.15</version>
         <exclusions>
            <exclusion>
               <groupId>javax.mail</groupId>
               <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.jms</groupId>
               <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
               <groupId>com.sun.jdmk</groupId>
               <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
               <groupId>com.sun.jmx</groupId>
               <artifactId>jmxri</artifactId>
            </exclusion>
         </exclusions>
         <scope>runtime</scope>
      </dependency>

      <!-- @Inject -->
      <dependency>
         <groupId>javax.inject</groupId>
         <artifactId>javax.inject</artifactId>
         <version>1</version>
      </dependency>
            
      <!-- Servlet -->
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.5</version>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>javax.servlet.jsp</groupId>
         <artifactId>jsp-api</artifactId>
         <version>2.1</version>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
      </dependency>
   
      <!-- Test -->
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.7</version>
         <scope>test</scope>
      </dependency>
      <!-- JSON  --> 
      <dependency>
         <groupId>com.fasterxml.jackson.core</groupId>
         <artifactId>jackson-databind</artifactId>
         <version>2.16.0</version>
      </dependency>
      
      <!-- Spring Security -->   
        <dependency>
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-web</artifactId>
             <version>${security.version}</version>
        </dependency>
        <dependency>
             <groupId>org.springframework.security</groupId>
             <artifactId>spring-security-config</artifactId>
             <version>${security.version}</version>
        </dependency>
        
        <dependency>
          <groupId>org.springframework.security</groupId>
          <artifactId>spring-security-taglibs</artifactId>
          <version>${security.version}</version>
       </dependency>   
      
      <!-- File Upload -->
      <dependency>
		 <groupId>commons-fileupload</groupId>
         <artifactId>commons-fileupload</artifactId>
         <version>${commons-fileupload-version}</version>
      </dependency>
	  <dependency>
		 <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
         <version>${commons-io-version}</version>
      </dependency>
      
      <!-- Validation-->
      <dependency>
		  <groupId>javax.validation</groupId>
		  <artifactId>validation-api</artifactId>
		  <version>2.0.1.Final</version>
	  </dependency>
	  <dependency>
		  <groupId>org.hibernate</groupId>
		  <artifactId>hibernate-validator</artifactId>
		  <version>5.4.2.Final</version>
	  </dependency>
	  
	  <!-- Web Flow-->
	  <dependency>
		  <groupId>org.springframework.webflow</groupId>
		  <artifactId>spring-webflow</artifactId>
		  <version>2.5.1.RELEASE</version>
	  </dependency>
	  
	  <!--Tiles -->
	  <dependency>
		  <groupId>org.apache.tiles</groupId>
		  <artifactId>tiles-servlet</artifactId>
		  <version>${org.apache.tiles-version}</version>
	  </dependency>
	  
	  <dependency>
		  <groupId>org.apache.tiles</groupId>
		  <artifactId>tiles-jsp</artifactId>
		  <version>${org.apache.tiles-version}</version>
	  </dependency>
	  
	  <dependency>
		  <groupId>org.apache.tiles</groupId>
		  <artifactId>tiles-extras</artifactId>
		  <version>${org.apache.tiles-version}</version>
	  </dependency>
      
      <!-- MySQL -->
      <dependency>
		  <groupId>org.springframework</groupId>
		  <artifactId>spring-jdbc</artifactId>
		  <version>${org.springframework-version}</version>
	  </dependency>
      <dependency>
		  <groupId>org.apache.commons</groupId>
		  <artifactId>commons-dbcp2</artifactId>
		  <version>2.5.0</version>
	  </dependency>	  	  
	 <dependency>
		  <groupId>mysql</groupId>
		  <artifactId>mysql-connector-java</artifactId>
		  <version>8.0.24</version>
	  </dependency>
	  
   </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

 

 

 

 

servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
   xmlns="http://www.springframework.org/schema/mvc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:beans="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:webflow="http://www.springframework.org/schema/webflow-config"
   xsi:schemaLocation="http://www.springframework.org/schema/mvc 
   http://www.springframework.org/schema/mvc/spring-mvc.xsd
      http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context 
      http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/webflow-config 
      http://www.springframework.org/schema/webflow-config/spring-webflow-config.xsd">

   <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
   
   <!-- Enables the Spring MVC @Controller programming model  -->
   <annotation-driven enable-matrix-variables="true" /> 

   <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
   <resources mapping="/resources/**" location="/resources/" />

   <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
   <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <beans:property name="prefix" value="/WEB-INF/views/" />
      <beans:property name="suffix" value=".jsp" />
   </beans:bean>
   
   
   
   <context:component-scan base-package="com.springmvc.*" />
   <!-- 컨트롤러 안의 것은 자동 생성함 // springmvc 안에 있는 @로 annotation한 객체는 모두 다 자동 생성해준다. -->
   <!-- 클래스 이름 위에 @붙은 것들 찾아서 new함 그리고 객체를 자기가 들고 있음 //꺼내서 넣어주는건 @autowired 만났을때 자동으로 변수에 대입해주는거 -->
  
  <beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  	<beans:property name="maxUploadSize" value="10240000"/>
  </beans:bean>
   

   
   <!-- DataSOurce설정 및 JdbcTemplate 빈객체 등록-->
   <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<beans:property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
		<beans:property name="url" value="jdbc:mysql://localhost:3306/WAGUDB?serverTimezone=UTC" />
		<beans:property name="username" value="root" />
		<beans:property name="password" value="1234" />
   </beans:bean>  
   
   <beans:bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
   		<beans:property name="dataSource" ref="dataSource" /> 
   </beans:bean>
   
</beans:beans>

 

 

 

 

root-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
   
   <!-- Root Context: defines shared resources visible to all other web components -->
      
</beans>

 

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday