Programming/Spring
-
[Spring] Spring Login Interceptor 설정2014.01.17
-
[Spring] Spring Ajax 사용 위한 JsonView 설정2014.01.13
-
java spring Maven 기반 개발환경 구성2013.04.30
[Spring] Spring Login Interceptor 설정
2014. 1. 17. 10:38
반응형
Spring Interceptor 설정
Spring login interceptor 설정을 위해 servlet.xml 설정 파일에 interceptor를 설정 합니다.
<bean id="loginUrlHandlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="order" value="1">
<property name="interceptors">
<list>
<ref bean="loginInterceptor"></ref>
</list>
</property>
</property>
</bean>
위와 같이 설정을 하고 Interceptor Class를 생성합니다.
@Service
public class LoginInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String path = request.getServletPath();
if(path.equals("/login.do")) {
return true;
} else {
@SuppressWarnings("unchecked")
Map<string, object> userMap = (Map<string, object>) request.getSession().getAttribute("userMap");
if(userMap == null) {
response.sendRedirect("/login.do");
return false;
} else {
return true;
}
}
}
}
login.do로 접근하는 url을 제외하고 세션을 체크하여 userMap에 데이터가 null 일 경우 login.do 페이지로 Redirect 처리를 수행합니다.
반응형
'Programming > Spring' 카테고리의 다른 글
[Spring] Environment와 @PropertySource (0) | 2014.02.05 |
---|---|
뷰 이름 명시적 지정 :ModelAndView와 String 리턴 타입 (1) | 2014.02.04 |
[Spring] log4j 설정파일 정보 (0) | 2014.01.17 |
[Spring] Spring Ajax 사용 위한 JsonView 설정 (0) | 2014.01.13 |
java spring Maven 기반 개발환경 구성 (0) | 2013.04.30 |
[Spring] Spring Ajax 사용 위한 JsonView 설정
2014. 1. 13. 13:58
반응형
Spring Ajax 설정
JsonView 설정을 이용하여 AJAX를 사용할 수 있게 설정하는 과정을 포스트 합니다.
pom.xml과 dispatcher에는 기본적으로 등록
pom.xml
net.sf.json-lib json-lib 2.4 jdk15 org.codehaus.jackson jackson-mapper-asl 1.6.4
DispatcherServlet XML 설정파일
-web.xml
action *.do action *.ajax
-TestController.java
@RequestMapping("/test.do")
public String test(@ModelAttribute("searchVO") CommentVO commentVO, ModelMap model) throws Exception {
return "test/test";
}
@RequestMapping("/test.ajax")
public ModelAndView testAjax(@ModelAttribute("searchVO") CommentVO commentVO, ModelMap model) throws Exception {
Map resultMap = new HashMap();
resultMap.put("result1", "test1");
resultMap.put("result2", "test222");
ModelAndView modelAndView = new ModelAndView("jsonView",resultMap);
return modelAndView;
}
Test.jsp
반응형
'Programming > Spring' 카테고리의 다른 글
[Spring] Environment와 @PropertySource (0) | 2014.02.05 |
---|---|
뷰 이름 명시적 지정 :ModelAndView와 String 리턴 타입 (1) | 2014.02.04 |
[Spring] log4j 설정파일 정보 (0) | 2014.01.17 |
[Spring] Spring Login Interceptor 설정 (0) | 2014.01.17 |
java spring Maven 기반 개발환경 구성 (0) | 2013.04.30 |
java spring Maven 기반 개발환경 구성
2013. 4. 30. 13:09
반응형
기본구성
http://odysseymoon.tistory.com/43
기본 Plugin 1
http://odysseymoon.tistory.com/44
기본 Plugin 2
http://odysseymoon.tistory.com/45
Test Project
반응형
'Programming > Spring' 카테고리의 다른 글
[Spring] Environment와 @PropertySource (0) | 2014.02.05 |
---|---|
뷰 이름 명시적 지정 :ModelAndView와 String 리턴 타입 (1) | 2014.02.04 |
[Spring] log4j 설정파일 정보 (0) | 2014.01.17 |
[Spring] Spring Login Interceptor 설정 (0) | 2014.01.17 |
[Spring] Spring Ajax 사용 위한 JsonView 설정 (0) | 2014.01.13 |