1. 주요 기능
1) 초기 페이징 처리된 리스트 화면(검색, 페이지처리, 답글 : 계층형 sql활용)
2) 등록 처리
기본 정보 등록
**첨부 파일 처리
3) 상세화면
- 수정 처리
- 삭제 처리
- 답글 처리
2. 개발 순서
1) Database 설계
메인 테이블 - 번호, 상위번호, 제목, 작성자, 내용, 등록일, 수정일, 조회수
첨부파일 테이블 - 번호, 경로명, 파일명, 등록일, 기타
게시판 고유번호 등록을 위한 sequence 객체
2) sql 문 작성
메인 조회 화면 sql :
답글에 대한 계층형 sql
페이지 처리를 위한 sql 조건문 처리
등록 sql
메인 화면
첨부파일 테이블
수정 sql
삭제 sql
3) vo 작성 cf) dto : 등록/수정/삭제, vo : 리스트/조회
list VO
검색 VO : 페이징 처리 관련된 속성..
4) 데이터 베이스 처리
dao
mapper
service
controller : 모델 데이터로 mapping
7) 메인 리스트 화면 구성(view단 구현)
form
페이징 처리
controller에 연동된 모델데이터로 화면 출력 처리.
해야 할 것
src/main/java/board
package 생성
controller,dao,vo,resource,util
src/main/java/resource
mapper 생성
configure 생성 (DB 서버 정보)
mybasits 생성
a00_com 파일에 bootstrap 파일 옮겨 사용
jsp 템플릿
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
import="java.util.*"
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="path" value="${pageContext.request.contextPath }"/>
<fmt:requestEncoding value="utf-8"/>
<!DOCTYPE html>
<%--
--%>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${path}/a00_com/bootstrap.min.css" >
<link rel="stylesheet" href="${path}/a00_com/jquery-ui.css" >
<style>
td{text-align:center;}
</style>
<script src="${path}/a00_com/jquery.min.js"></script>
<script src="${path}/a00_com/popper.min.js"></script>
<script src="${path}/a00_com/bootstrap.min.js"></script>
<script src="${path}/a00_com/jquery-ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://developers.google.com/web/ilt/pwa/working-with-the-fetch-api" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
<%--
--%>
});
</script>
</head>
<body>
<div class="jumbotron text-center">
<h2 data-toggle="modal" data-target="#exampleModalCenter">타이틀</h2>
</div>
<div class="container">
<form id="frm01" class="form-inline" method="post">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark">
<input class="form-control mr-sm-2" placeholder="제목" />
<input class="form-control mr-sm-2" placeholder="내용" />
<button class="btn btn-info" type="submit">Search</button>
</nav>
</form>
<table class="table table-hover table-striped">
<col width="10%">
<col width="50%">
<col width="15%">
<col width="15%">
<col width="10%">
<thead>
<tr class="table-success text-center">
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성일</th>
<th>조회</th>
</tr>
</thead>
<tbody>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
</tbody>
</table>
</div>
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">타이틀</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="frm02" class="form" method="post">
<div class="row">
<div class="col">
<input type="text" class="form-control" placeholder="사원명 입력" name="ename">
</div>
<div class="col">
<input type="text" class="form-control" placeholder="직책명 입력" name="job">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>board</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>default.htm</welcome-file>
</welcome-file-list>
<!-- 1. front controller을 위한 컨테이너와 객체선언 -->
<servlet>
<!-- dispatcher-servlet.xml -->
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--
urlpattern을 어떻게 설정하느냐에 따라서
*.do : http://localhost:7080/springweb/start01.do
마지막에 .do가 있을 때만 frontcontroller을 처리
/ : 모두 스프링 프레임워크 처리.
-->
<!-- 2. 요청값에 대한 한글 encoding을 위한 filtering 처리:get/post 방식 모두 적용 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:websocket="http://www.springframework.org/schema/websocket"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/websocket
http://www.springframework.org/schema/websocket/spring-websocket.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
" >
<context:component-scan base-package="board">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
<context:property-placeholder location="classpath:resource/configure"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.user}"/>
<property name="password" value="${jdbc.pass}"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:resource/mybatis.Spring.xml"/>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="board.dao"/>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="1"/>
</bean>
<!--
3. 기타 뷰 (json, 파일다운로드, 엑셀 다운로드 등등 )
-->
<bean id="btnViewResolver"
class="org.springframework.web.servlet.view.BeanNameViewResolver">
<property name="order" value="0"/>
</bean>
<!--
4. json뷰
-->
<bean id="pageJsonReport" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView">
<property name="contentType" value="text/html;charset=utf-8"/>
</bean>
<!--
5. 파일업로드 뷰
-->
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
<!--
6.다운로드 뷰
-->
<bean id="downloadViewer" class="board.util.DownloadViewer"/>
</beans>
resource/configure
자신의 db환경에 맞춰 입력하시면 됩니다.
# 파일 업로드 정보
upload=C:/a02_javaexp/board/src/main/webapp/z01_fileupload/
'JAVA' 카테고리의 다른 글
JAVA 게시판 처리(조회, 페이징처리)-2 (0) | 2022.10.07 |
---|---|
JAVA 게시판 처리(기본구성)-1 (0) | 2022.10.07 |
JAVA 포트 오류, 톰캣 서버 충돌 (0) | 2022.10.06 |
JAVA fullcalendar 달력 캘린더 처리 (1) | 2022.10.04 |
JAVA 다국어처리 (0) | 2022.10.04 |