jsp framework1(EgovController.java)
jsp에서 필요한 java파일은 Controller.java/Service.java/ServiceImpl.java/VO.java/DAO.java 이다.
이번에는 Controller.java 를 보도록하겠다.
EgovController.java
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package egovframework.example.sample.web;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;
import org.springmodules.validation.commons.DefaultBeanValidator;
import egovframework.example.sample.service.BoardVO;
import egovframework.example.sample.service.EgovBoardService;
import egovframework.example.sample.service.LoginVO;
import egovframework.rte.fdl.property.EgovPropertyService;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
/**
* @Class Name : EgovSampleController.java
* @Description : EgovSample Controller Class
* @Modification Information
* @
* @ 수정일 수정자 수정내용
* @ --------- --------- -------------------------------
* @ 2009.03.16 최초생성
*
* @author 개발프레임웍크 실행환경 개발팀
* @since 2009. 03.16
* @version 1.0
* @see
*
* Copyright (C) by MOPAS All right reserved.
*/
@Controller
public class EgovBoardController {
/** EgovSampleService */
@Resource(name = "boardService")
private EgovBoardService boardService;
/** EgovPropertyService */
@Resource(name = "propertiesService")
protected EgovPropertyService propertiesService;
/** Validator */
@Resource(name = "beanValidator")
protected DefaultBeanValidator beanValidator;
/*ajax 사용을 이*/
@Resource(name="ajaxMainView")
public MappingJacksonJsonView ajaxMainView;
@RequestMapping(value = "/boardWrite.do")//화면을 열때..
public String boardWrite(@ModelAttribute("boardVO") BoardVO vo, ModelMap model) throws Exception{
return "sample/boardWrite";
}
@RequestMapping(value = "/boardModify.do")//화면을 열때..
public String boardModify(@ModelAttribute("boardVO") BoardVO vo, ModelMap model) throws Exception{
boardService.boardHitCount(vo);
List<?> boardList = boardService.selectBoardDetail(vo);
model.addAttribute("boardList", boardList);
return "sample/boardModify";
}
@RequestMapping(value = "/insertBoard.do")
public String insertBoard(@ModelAttribute("boardVO") BoardVO vo, ModelMap model) throws Exception {
//System.out.println("==empno :"+empVO.getEmpno());
boardService.insertBoard(vo);
return "sample/boarWrite";
}
@RequestMapping(value = "/boardList.do")
public String selectBoardList(@ModelAttribute("boardVO") BoardVO vo, ModelMap model,HttpServletRequest request) throws Exception {
vo.setPageUnit(propertiesService.getInt("pageUnit"));
vo.setPageSize(propertiesService.getInt("pageSize"));
System.out.println("FirstIndex:"+vo.getFirstIndex());
/** pageing setting
* PaginationInfo : 페이징 처리를 위한 빈 클래스
* */
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(vo.getPageIndex());
paginationInfo.setRecordCountPerPage(vo.getPageUnit());
paginationInfo.setPageSize(vo.getPageSize());
vo.setFirstIndex(paginationInfo.getFirstRecordIndex());
vo.setLastIndex(paginationInfo.getLastRecordIndex());
vo.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
int totCnt = boardService.selectBoardTotalCount(vo);
List<?> boardList = boardService.selectBoardList(vo);
paginationInfo.setTotalRecordCount(totCnt);
int topNumber=totCnt - ((vo.getPageIndex()-1)* vo.getPageUnit());
System.out.println("topNumber:"+topNumber);
model.addAttribute("paginationInfo", paginationInfo);
model.addAttribute("boardList", boardList);
model.addAttribute("topNumber", topNumber);
model.addAttribute("sch_type",vo.getSch_type());
model.addAttribute("search_value",vo.getSearch_value());
return "sample/boardList1";
}
@RequestMapping(value = "/deleteBoard.do")
public ModelAndView deleteBoard(@ModelAttribute("boardVO") BoardVO vo) throws Exception {
System.out.println("=========deleteBoard Start=============");
HashMap<String,String> model = new HashMap<String,String>();
int aa = boardService.selectBoardCheckCount(vo);
model.put("aa",Integer.toString(aa));
System.out.println("unq:"+vo.getUnq());
System.out.println("pwd:"+vo.getPwd());
if(aa > 0){
boardService.deleteBoard(vo);
}
return new ModelAndView(ajaxMainView,model);
}
@RequestMapping(value = "/updateBoard.do")
public ModelAndView updateBoard(@ModelAttribute("boardVO") BoardVO vo) throws Exception{
System.out.println("=====================updateBoard Start===========");
HashMap<String,String> model= new HashMap<String,String>();
int number=boardService.selectBoardCheckCount(vo);
model.put("number",Integer.toString(number));
if(number > 0){
boardService.updateBoard(vo);
}
return new ModelAndView(ajaxMainView,model);
}
@RequestMapping(value = "/loginTest.do")//화면을 열때..
public String loginTest() throws Exception{
return "sample/loginTest";
}
@RequestMapping(value = "/loginConfirm.do")//화면을 열때..
public String loginTest(@ModelAttribute("LoginVO") LoginVO vo,HttpServletRequest request, ModelMap model ) throws Exception{
System.out.println("user id:"+vo.getUserId());
model.addAttribute("userId",vo.getUserId());
return "redirect:/boardLogin.do";
}
@RequestMapping(value = "/boardLogin.do")//화면을 열때..
public String boardLogin(@ModelAttribute("LoginVO") LoginVO vo,HttpServletRequest request, ModelMap model ) throws Exception{
String id=request.getParameter("userId");
model.addAttribute("userId",vo.getUserId());
return "sample/boardLogin";
}
}
'개발 > jsp' 카테고리의 다른 글
jsp framework1(boardList1.jsp) (0) | 2015.11.18 |
---|---|
JSTL 라이브러리 태그 (0) | 2015.10.29 |
프레임워크 어떻게 돌아가는가? (2) | 2015.10.27 |
JSP개발에 디버깅에 필요한 로그확인/쿼리까지 확인가능(log4j)v3e0e4e5a (0) | 2015.10.22 |
jsp (0) | 2015.10.16 |
댓글