스프링

조회수 제한 처리 세션 저장

 

서비스 


	@Transactional
	@Override
	public BoardVO boardRead(Integer bno, HttpSession session) {
		BoardVO vo =null;
		try{
			vo=boardDAO.boardRead(bno);
		
			
			//조회수 증가	
			
			long update_time =0;
			//세션에 저장된 조회시간 검색
			if(session.getAttribute("update_time" +bno) !=null){
				update_time =(long)session.getAttribute("update_time"+ bno);	
			}
			//시스템 현재시간
			long current_time =System.currentTimeMillis();
			if(current_time - update_time > 24*60*601000){
				boardDAO.viewCntUpdate(bno);
				session.setAttribute("update_time"+bno, current_time);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return vo;
	}

 

root-context.xml 혹은  servlet-context.xml 에  상단에 추가 한다. 안 될 경우  두곳 모두 추가 한다.

	
	<!-- 트랜잭션 처리 -->
	<tx:annotation-driven/>

 

 

 

about author

PHRASE

Level 60  머나먼나라

신뢰가 없는 우정은 있을 수 없고, 언행일치가 안 되는 신뢰란 있을 수 없다. -새뮤얼 존슨

댓글 ( 4)

댓글 남기기

작성

스프링 목록    more