Programming
-
[Spring] interceptor login check2015.02.11
-
웹 사이트 성능 최적화 분석 자동화: YSlow와 CI 서버 연동2015.01.22
-
[jQuery] each break/continue2015.01.22
-
[jQuery] loadingbar plugin2014.09.19
[Spring] interceptor login check
Spring InterCeptor 를 이용한 Session Login Check
InterCeptor에서 제공하는 3가지 메소드가 각각 실행되는 시점.
- preHandle: Controller 실행 요청 전
- postHandle: view(jsp)로 forward 되기 전에
- afterCompletion: 요청이 끝난 뒤
session check 시점은 dispatcher -> controller 로 요청이 오기 전에 실행..되야 하므로 preHandle 메소드 시점에 처리.
- CommonInterceptor.java
public class CommonInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
log.debug("===============================preHandler===============================");
if (SessionUtils.getSessionVO() == null) {
//14.11.25 jp add..
//session validation check order & mypage * method type : submit, ajax
if ((request.getRequestURI().indexOf("/biz/ord/order/") > -1) || (request.getRequestURI().indexOf("/biz/mpg/") > -1)) {
String ajaxCall = (String) request.getHeader("AJAX");
if ("true".equals(ajaxCall)) {
response.sendError(901);
} else {
response.sendRedirect(Globals.PROTOCOL_HTTPS + Globals.DOMAIN + "/base/login/loginForm.do");
response.flushBuffer();
}
return false;
}
}
return true;
}
}
- Sevlet-interceptor.xml
submit에 경우는 sendRedirect 로 리다이렉트가 가능하지만, ajax Call에 경우는 sendRedirect가 호출 되더라도 Callback 처리 되기때문에 추가해줘야 한다.
ajax 공통 함수에 jqXHR.status = 901로 리턴 될 경우 로그인 페이지로 핸들링 처리를 추가해준다.
- ajax 호출시 beforeSend 에 ajax 호출을 Header에 기록.
$.ajax({
beforeSend: function (xmlHttpRequest) {
xmlHttpRequest.setRequestHeader("AJAX", "true");
}
});
'Programming > Spring' 카테고리의 다른 글
[Spring] org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'HEAD' not supported
Request method 'HEAD' not supported 오류에 대한 대처 방법.
프로젝트 막바지에 위와 같은 오류에 직면 했다..ㅜ 첨 보는 오류..
그동안 너무 쉬엄쉬엄 했나..기본이 부족..
HTTP method GET, POST 이외에...PUT, DELETE...등 그 중 HEAD....
원리는 간단하다. web.xml 전 단계에서 doFilter 를 이용해 우회 처리를..
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
logger.debug("========== isHttpHead(httpServletRequest) : {}", isHttpHead(httpServletRequest));
if (isHttpHead(httpServletRequest)) {
chain.doFilter(new ForceGetRequestWrapper(httpServletRequest), response);
} else {
chain.doFilter(new FilteredRequest(request), response);
}
}
private boolean isHttpHead(HttpServletRequest request) {
return "HEAD".equals(request.getMethod());
}
private class ForceGetRequestWrapper extends HttpServletRequestWrapper {
public ForceGetRequestWrapper(HttpServletRequest request) {
super(request);
}
public String getMethod() {
return "GET";
}
}
public void destroy() {
}
}
doFilter에 분기문을 추가하여 HEAD 요청시 GET으로 Method 를 변경한다.
http://axelfontaine.com/blog/http-head.html http://forum.spring.io/forum/spring-projects/web/89981-request-method-head-not-supported
Legacy forums will be shutdown February 28
In 2014, we announced the retirement of our legacy forum, forum.spring.io, in favor of providing an improved community experience on stackoverflow.com. As part of that announcement, we put our forum into read-only mode, preserving forum posts that were ref
spring.io
'Programming > Spring' 카테고리의 다른 글
Spring Annotation @Componenet, @Configuration 차이 (0) | 2022.06.21 |
---|---|
[Spring] interceptor login check (0) | 2015.02.11 |
mybatis cache 설정 (0) | 2014.05.14 |
[Spring] org.xml.sax.SAXParseException: Document root element "configuration", must match DOCTYPE root "mapper" (0) | 2014.05.13 |
[오류] org.springframework.jdbc.datasource.DataSourceTransactionManager 빈 생성 에러 (0) | 2014.05.13 |
웹 사이트 성능 최적화 분석 자동화: YSlow와 CI 서버 연동
번역본
http://helloworld.naver.com/helloworld/textyle/303083
https://developer.yahoo.com/performance/rules.html
'Programming > Frontend' 카테고리의 다른 글
장바구니 주문금액 재계산 스크립트 (0) | 2015.04.06 |
---|---|
[jQuery] multi element each (0) | 2015.03.31 |
[jQuery] each break/continue (0) | 2015.01.22 |
[jQuery] loadingbar plugin (0) | 2014.09.19 |
jquery ajax method 정리 (0) | 2014.03.12 |
[jQuery] each break/continue
jQuery each break/continue
$.each(giftInfo, function(i) {
if(giftInfo[i].ORD_PSS_QTY <=0) {
alert(J.getMessage("ord.warning.028", [giftInfo[i].PRD_NM]));
//freeGift Stock check
$(location).attr("href", "${refURL}");
flag = false;
return false; //break each loop 빠져나옴
return true; //continue each loop 계속 수행
}
}
);
'Programming > Frontend' 카테고리의 다른 글
[jQuery] multi element each (0) | 2015.03.31 |
---|---|
웹 사이트 성능 최적화 분석 자동화: YSlow와 CI 서버 연동 (0) | 2015.01.22 |
[jQuery] loadingbar plugin (0) | 2014.09.19 |
jquery ajax method 정리 (0) | 2014.03.12 |
jQuery multi redio button valid check (0) | 2014.02.13 |
[jQuery] loadingbar plugin
- jquery.loadinbar.js

- sample.jsp

'Programming > Frontend' 카테고리의 다른 글
웹 사이트 성능 최적화 분석 자동화: YSlow와 CI 서버 연동 (0) | 2015.01.22 |
---|---|
[jQuery] each break/continue (0) | 2015.01.22 |
jquery ajax method 정리 (0) | 2014.03.12 |
jQuery multi redio button valid check (0) | 2014.02.13 |
[ajax] JSONP CROSS SITE 응답 받기 (0) | 2014.02.12 |