Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egov #2

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4fcd97b
The superclass "javax.servlet.http.HttpServlet" was not found on the
holy1017 Nov 11, 2015
0b02398
..
holy1017 Nov 11, 2015
1ef9757
jsp 클래스 낫파운드 뜨던거 수정
holy1017 Nov 11, 2015
cdc8e67
...
holy1017 Nov 11, 2015
75017ef
으어 거의다 인포트 했다
holy1017 Nov 12, 2015
d640a02
예외파일 추가
holy1017 Nov 12, 2015
73e5118
업로드 테스트
holy1017 Nov 12, 2015
9e8c1f7
.
holy1017 Nov 12, 2015
812623b
다른곳으로 영향 안미치게 스캔 범위를 서블릿 안으로 변경
holy1017 Nov 12, 2015
6b5262e
퍼스트:게시판 작성시 빈값 오류처리
holy1017 Nov 12, 2015
12ac2b3
log4 가 jdbc 로그 출력을 못함.
holy1017 Nov 12, 2015
2652622
log4 와 logback를 쓰는곳이 서로 다른듯
holy1017 Nov 12, 2015
569de38
http://addio3305.tistory.com/85 따라하기 완료
holy1017 Nov 12, 2015
f9f0b48
그냥 양쪽 로그 다 사용해야겠네.
holy1017 Nov 12, 2015
48d4acb
http://addio3305.tistory.com/89 따라하는중
holy1017 Nov 12, 2015
6c133b7
로그 출력 안됨 왜..?
holy1017 Nov 12, 2015
c52268b
갑자기 로그가 출력 안되는 원인을 찿아보는중.
holy1017 Nov 13, 2015
3b2ac86
전자정부 프레임워크 등록시키면 로그 출력 안됨.
holy1017 Nov 13, 2015
fec9924
의존성 제거 완료
holy1017 Nov 13, 2015
ba03c97
페이징 처리전으로 복구
holy1017 Nov 13, 2015
076fcf2
페이징 처리 완료
holy1017 Nov 13, 2015
6084a2a
전자정부의 로깅 의존성 제거
holy1017 Nov 13, 2015
0e27e10
프로젝트명 변경
holy1017 Nov 13, 2015
3d1a877
테스트
holy1017 Nov 13, 2015
24edc25
트랜젝션 테스트 해볼려다 중단.
holy1017 Nov 16, 2015
ecc04e2
아...의욕 없다아....
holy1017 Nov 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
페이징 처리전으로 복구
예제 잘못 따라함 
다시 시작
  • Loading branch information
holy1017 committed Nov 13, 2015
commit ba03c9733d9a44bd92193cf4c5d696bf60c086d7
18 changes: 10 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -84,9 +84,9 @@ dependencies {
compile 'cglib:cglib-nodep:2.2'//aop 사용시 스프링 3.1 이하는 이게 필요

compile ('egovframework.rte:egovframework.rte.ptl.mvc:3.5.0'){//전자정부 프레임워크
exclude group:'org.apache.logging.log4j', module:'log4j-core'
exclude group:'org.apache.logging.log4j', module:'log4j-slf4j-impl'
exclude group:'org.slf4j', module:'log4j-over-slf4j'
exclude group:'org.apache.logging.log4j', module:'log4j-core'//나는 로그백을 이용할것이므로 이 걸 제거
exclude group:'org.apache.logging.log4j', module:'log4j-slf4j-impl'//나는 로그백을 이용할것이므로 이 걸 제거
exclude group:'org.slf4j', module:'log4j-over-slf4j'//나는 로그백을 이용할것이므로 이 걸 제거
}
//testCompile 'junit:junit:${version.release}'
}
@@ -103,12 +103,14 @@ eclipse {


// commons-logging, log4j, jul 의존성 제거

configurations {
all.collect { configuration ->
// configuration.exclude group: 'commons-logging', module: 'commons-logging'
// configuration.exclude group: 'log4j', module: 'log4j'
// configuration.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
// configuration.exclude group: 'org.slf4j', module: 'slf4j-jcl'
// configuration.exclude group: 'org.slf4j', module: 'slf4j-jdk14'
//이걸 안넣으면 로그가 이중으로 출력됨. 그것도 정규식이 지정 안된 오리지날 형태로
configuration.exclude group: 'commons-logging', module: 'commons-logging'
configuration.exclude group: 'log4j', module: 'log4j'
configuration.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
configuration.exclude group: 'org.slf4j', module: 'slf4j-jcl'
configuration.exclude group: 'org.slf4j', module: 'slf4j-jdk14'
}
}
3 changes: 2 additions & 1 deletion src/main/java/common/logger/LoggerInterceptor.java
Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@ public class LoggerInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (log.isDebugEnabled()) {
log.debug("====================================== START ======================================");
log.debug(" Request URI \t: " + request.getRequestURI()+"\t /Method \t:"+request.getMethod());
log.debug("Request URI \t:" + request.getRequestURI());
log.debug("Request Method \t:"+request.getMethod());
}
return super.preHandle(request, response, handler);
}
62 changes: 62 additions & 0 deletions src/main/java/first/AbstractDAO.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package first;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.util.StringUtils;

import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

public class AbstractDAO {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@@ -57,4 +62,61 @@ public List selectList(String queryId, Object params) {
printQueryId(queryId);
return sqlSession.selectList(queryId, params);
}

/**
* 페이징 처리용
*
* @param queryId
* @param params
* @return
*/
@SuppressWarnings({
"rawtypes", "unchecked"
})
public Map selectPagingList(String queryId, Object params) {
printQueryId(queryId);

Map<String, Object> map = (Map<String, Object>) params;
PaginationInfo paginationInfo = null;

if (map.containsKey("currentPageNo") == false || StringUtils.isEmpty(map.get("currentPageNo")) == true)
map.put("currentPageNo", "1");

paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(Integer.parseInt(map.get("currentPageNo").toString()));
if (map.containsKey("PAGE_ROW") == false || StringUtils.isEmpty(map.get("PAGE_ROW")) == true) {
paginationInfo.setRecordCountPerPage(15);
} else {
paginationInfo.setRecordCountPerPage(Integer.parseInt(map.get("PAGE_ROW").toString()));
}
paginationInfo.setPageSize(10);

int start = paginationInfo.getFirstRecordIndex();
int end = start + paginationInfo.getRecordCountPerPage();
map.put("START", start + 1);
map.put("END", end);

params = map;

Map<String, Object> returnMap = new HashMap<String, Object>();
List<Map<String, Object>> list = sqlSession.selectList(queryId, params);

if (list.size() == 0) {
map = new HashMap<String, Object>();
map.put("TOTAL_COUNT", 0);
list.add(map);

if (paginationInfo != null) {
paginationInfo.setTotalRecordCount(0);
returnMap.put("paginationInfo", paginationInfo);
}
} else {
if (paginationInfo != null) {
paginationInfo.setTotalRecordCount(Integer.parseInt(list.get(0).get("TOTAL_COUNT").toString()));
returnMap.put("paginationInfo", paginationInfo);
}
}
returnMap.put("result", list);
return returnMap;
}
}
18 changes: 18 additions & 0 deletions src/main/java/first/CommandMap.java
Original file line number Diff line number Diff line change
@@ -5,11 +5,16 @@
import java.util.Map;
import java.util.Map.Entry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.Set;

public class CommandMap {

private final Logger log = LoggerFactory.getLogger(this.getClass());

Map<String, Object> map = new HashMap<String, Object>();

public Object get(String key) {
@@ -58,6 +63,7 @@ public Map<String, Object> getMap() {

/**
* 리다이랙트시 키갑을 그대로 넘겨줌
*
* @param redirect
* @return
*/
@@ -66,4 +72,16 @@ public void redirect(RedirectAttributes redirect) {
redirect.addFlashAttribute(key, map.get(key));
}
}

public void mapPrint() {
if (log.isDebugEnabled()) {
if (map.isEmpty()) {
log.debug("Map is empty!");
} else {
for (String key : map.keySet()) {
log.debug("key:{} \t value:{}", key, map.get(key));
}
}
}
}
}
60 changes: 40 additions & 20 deletions src/main/java/first/FirstController.java
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@

import common.utill.UtilsEmpty;
import common.utill.UtilsUUID;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

@Controller
public class FirstController {
@@ -45,6 +46,20 @@ public ModelAndView openBoardList(Map<String, Object> commandMap) throws Excepti
List<Map<String, Object>> list = service.selectBoardList(commandMap);
mv.addObject("list", list);

// commandMap.mapPrint();
// Map<String, Object> resultMap =
// service.selectBoardList(commandMap.getMap());
//
// if (log.isDebugEnabled()) {
// log.debug("paginationInfo" +
// resultMap.get("paginationInfo").toString());
// log.debug("result" + resultMap.get("result").toString());
// }

// mv.addObject("paginationInfo", (PaginationInfo)
// resultMap.get("paginationInfo"));
// mv.addObject("list", resultMap.get("result"));

return mv;
}

@@ -96,35 +111,40 @@ public String openBoardWrite(CommandMap commandMap, HttpSession session) throws
* @throws Exception
*/
@RequestMapping(value = "/insertBoard", method = RequestMethod.POST)
public String insertBoard(CommandMap commandMap, HttpServletRequest request,HttpServletResponse response,RedirectAttributes redirect) throws Exception {
//ModelAndView mv = new ModelAndView("redirect:openBoardList");

//log.debug("TITLE:"+commandMap.get("TITLE"));

public String insertBoard(
CommandMap commandMap,
HttpServletRequest request,
HttpServletResponse response,
RedirectAttributes redirect) throws Exception {
// ModelAndView mv = new ModelAndView("redirect:openBoardList");

// log.debug("TITLE:"+commandMap.get("TITLE"));

if (UtilsEmpty.isEmpty(commandMap.get("TITLE"))) {
//response.sendRedirect("boardList");
//redirect.addFlashAttribute("CONTENTS", commandMap.get("CONTENTS"));
// response.sendRedirect("boardList");
// redirect.addFlashAttribute("CONTENTS",
// commandMap.get("CONTENTS"));
commandMap.redirect(redirect);
redirect.addFlashAttribute("msg", "TITLE 내용이 없습니다");
return "redirect:openBoardWrite";
}
if (UtilsEmpty.isEmpty(commandMap.get("CONTENTS"))) {
//response.sendRedirect("boardList");
//redirect.addFlashAttribute("TITLE", commandMap.get("TITLE"));
// response.sendRedirect("boardList");
// redirect.addFlashAttribute("TITLE", commandMap.get("TITLE"));
commandMap.redirect(redirect);
redirect.addFlashAttribute("msg", "CONTENTS 내용이 없습니다");
return "redirect:openBoardWrite";
}

List<Map<String, Object>> faillist=service.insertBoard(commandMap.getMap(), request);
log.debug("UtilsEmpty.isEmpty(faillist)"+UtilsEmpty.isEmpty(faillist));
log.debug("faillist:"+faillist);
List<Map<String, Object>> faillist = service.insertBoard(commandMap.getMap(), request);

log.debug("UtilsEmpty.isEmpty(faillist)" + UtilsEmpty.isEmpty(faillist));
log.debug("faillist:" + faillist);
if (!UtilsEmpty.isEmpty(faillist)) {
//mv.addObject("failList", faillist);
// mv.addObject("failList", faillist);
redirect.addFlashAttribute("msg", faillist);
}
}

return "redirect:openBoardList";
}

@@ -136,7 +156,7 @@ public ModelAndView openBoardDetail(CommandMap commandMap) throws Exception {
mv.addObject("map", map.get("map"));// 기존 상세글
// log.debug(map.get("list")==null);
// log.debug(map.get("list").equals(""));
log.debug("UtilsEmpty.isEmpty(map.get:"+UtilsEmpty.isEmpty(map.get("list")));
log.debug("UtilsEmpty.isEmpty(map.get:" + UtilsEmpty.isEmpty(map.get("list")));

if (!UtilsEmpty.isEmpty(map.get("list")))
mv.addObject("list", map.get("list"));// 첨부파일 목록
@@ -146,13 +166,13 @@ public ModelAndView openBoardDetail(CommandMap commandMap) throws Exception {

@RequestMapping(value = "/openBoardUpdate")
public ModelAndView openBoardUpdate(CommandMap commandMap) throws Exception {

log.debug("openBoardUpdate");

ModelAndView mv = new ModelAndView("boardUpdate");

Map<String, Object> map = service.selectBoardDetail(commandMap.getMap());

mv.addObject("map", map.get("map"));
if (!UtilsEmpty.isEmpty(map.get("list")))
mv.addObject("list", map.get("list"));
2 changes: 1 addition & 1 deletion src/main/java/first/FirstDAO.java
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ public class FirstDAO extends AbstractDAO {

//@SuppressWarnings("unchecked")
public List<Map<String, Object>> selectBoardList(Map<String, Object> map) throws Exception {
return (List<Map<String, Object>>) selectList("First.selectBoardList", map);
return (List<Map<String, Object>>)selectList("First.selectBoardList", map);
}

public void insertBoard(Map<String, Object> map) {
14 changes: 7 additions & 7 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -76,43 +76,43 @@
</logger>
<logger
name="common"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="sample"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="defult"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="board2"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="board"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="scott"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
<logger
name="first"
additivity="true">
additivity="false">
<level value="debug" />
<appender-ref ref="console" />
</logger>
6 changes: 6 additions & 0 deletions src/main/webapp/WEB-INF/first/jsp/boardList.jsp
Original file line number Diff line number Diff line change
@@ -51,6 +51,12 @@
</c:choose>
</tbody>
</table>

<c:if test="${not empty paginationInfo}">
<ui:pagination paginationInfo = "${paginationInfo}" type="text" jsFunction="fn_search"/>
</c:if>
<input type="hidden" id="currentPageNo" name="currentPageNo"/>

<br />
<a href="#this" class="btn" id="write">글쓰기</a>

4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/first/servlet/servlet-first.xml
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@
</beans:bean>

<!-- 전자정부 페이징 설정 -->
<!-- <beans:bean
<beans:bean
id="textRenderer"
class="egovframework.rte.ptl.mvc.tags.ui.pagination.DefaultPaginationRenderer" />
<beans:bean
@@ -95,7 +95,7 @@
value-ref="textRenderer" />
</beans:map>
</beans:property>
</beans:bean> -->
</beans:bean>

<context:component-scan base-package="first" />
<context:component-scan base-package="common" />
20 changes: 20 additions & 0 deletions src/main/webapp/WEB-INF/sql/common/sql-common.xml
Original file line number Diff line number Diff line change
@@ -2,6 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="common">
<sql id="pagingPre">
<![CDATA[
SELECT
AAA.*
FROM(
SELECT
COUNT(*) OVER() AS TOTAL_COUNT,
AA.*
FROM(
]]>
</sql>

<sql id="pagingPost">
<![CDATA[
) AA
) AAA
WHERE
AAA.RNUM BETWEEN #{START} AND #{END}
]]>
</sql>
<select
id="selectFileInfo"
parameterType="hashmap"
Loading