List

수요일, 5월 25, 2016

MySQL - DataBase engine 변경하기


  • 쉽다 ALTER TABLE (테이블명) ENGINE = (변경할엔진)

1
ALTER TABLE d_user ENGINE = InnoDB;
cs

월요일, 5월 23, 2016

MySQL - Date Format


  • date_format( [원하는날짜], [날짜 형식] ) 을 활용하여 원하는 형식대로 날짜를 출력할 수 있다

1
date_format(createDate,"%Y-%m-%d %h:%i"),
cs


  • 출력 결과



수요일, 5월 18, 2016

Spring - Intercepter 사용하기


  • xml 단 설정 ( 이번 경우는 dispatcher-servlet )
  • mapping path ="/*/*" - 스프링 시큐리티와 같은방식으로 인터셉트할 url pattern을 매핑 가능
  • 아래에 선언된 bean class는 intercept 했을때 사용될 class

1
2
3
4
5
6
7
8
9
10
    <mvc:interceptors>
        <!-- visor 윈도우 interceptor -->
        <mvc:interceptor>
            <mvc:mapping path="/visor_w/*"/>
            <bean class="comm.utill.visor_wInterceptor"></bean>
        </mvc:interceptor>
        <!-- 
        추가로 여러가지 패턴에 해당하는 
        인터셉터 설정가능-->
    </mvc:interceptors>
cs


  • visor_wInterceptor - HandlerInterceptorAdapter 추상클래스로 사용
    • preHandle 메소드 - 컨트롤러가 호출되기전에 실행됨
      • return 값이 false 일경우 해당 페이지로 보내주지않음
        • 추가 redirect 처리 역시 가능
      • true 일경우 해당 페이지로 보내줌
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
 
public class visor_wInterceptor extends HandlerInterceptorAdapter{
    
    @Autowired
    private OwnerDao ownerDao;
    
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object handler){
 
        boolean result=false;
        
        //자신의 하위매장인지여부 체크 
        try {
            Authentication authority = SecurityContextHolder.getContext().getAuthentication();
            
            customUserDetails userDetails=(customUserDetails) authority.getDetails();
            
            int u_seq = userDetails.getSeq();//현재 유저 seq
            int w_seq=Integer.parseInt(request.getParameter("w_seq"));//요청한 하위 매장 seq
            
            System.out.println("추가 window 요청한 seq : "+u_seq);
            System.out.println("추가 window에 나올 seq : "+w_seq);
            
            System.out.println("하위 매장 들");
            for(Integer i : ownerDao.getMyOwnerSeq(u_seq)){
                if(i == w_seq){
                    result=true;
                };
            }
            if(!result){
                try {
                    response.sendRedirect("/Dongnero/main");
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        
        
        return result;
    }
 
}
 
cs

d