나의 마음을 ctrl+c,너의 가슴에 ctrl+v

Spring3 properites call

설정

<util:properties id="globals" location="classpath:/egrovframework/egovProps/globals.properties"/>

<!-- Messages .properties Path -->
<util:list id="configMessages" list-class="java.util.LinkedList">

   <value>egovframework.message.com.message-common</value>

   <!-- 
   <value>egovframework.message.com.validation</value>            <value>egovframework.message.com.javascript</value>
    -->

</util:list>


호출 - xml

<property name="maxUploadSize">
    <value>#{globals['File.maxUploadSize']}</value>
</property>


호출 - java

@Value("#{globals['Server.charset']}")
private String charset;

@Value("#{prop['global.arrs'].split(',')}") private String arr; // split 처리

// Bean 으로 생성되었으므로, Autowired 가능
@Autowired Properties globals;


호출 - jsp

<spring:eval expression="@config['']" />


'java > framework' 카테고리의 다른 글

jsp 에서 Spring framework 연동  (0) 2013.07.19
Spring Controller intercepter By 3.0 , annotation  (0) 2012.07.06


1. 연계 bean 설정 (context-xx.xml) - annotation 인경우 context:component 설정


<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans    
                        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/task
                        http://www.springframework.org/schema/task/spring-task.xsd
                        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

    <context:component-scan base-package="portal">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
    </context:component-scan>

</beans>


2. jsp page

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.MessageSource"%>
<%@page import="java.util.Locale"%><%

WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());

// MenuService 가 bean 또는 annotation 으로 설정되어있어야 함.
MenuService menuService = (MenuService) ctx.getBean("MenuService");
%>

 

'java > framework' 카테고리의 다른 글

Spring3 properites call  (0) 2016.02.04
Spring Controller intercepter By 3.0 , annotation  (0) 2012.07.06

env : Spring3.0, annotation 사용

*Controller 단 모든 method 에서 권한확인 등의 중복작업을 일괄적으로 할수 있다.

필요1. intercepterHandler 구현
필요2. servlet context bean 등록

사용을 위해, 구현된 Controller 에 HandlerInterceptorAdapter 를 extend 한다.

필요1. intercepter controller 작성... 아래의 구성형태로...

package xxx.xxx.xxx

import ...

public class ExampleHandler extends HandlerInterceptorAdapter {
   
    @Override
    public boolean preHandler(HttpServletRequest request,HttpServletResponse response, Object handler) {
    /* preHandler Controller 유입전 실행됨. */
 boolean rtn = false;
 
 // 검증하여 false 인경우는 가급적 Exception 처리

 return rtn
    }
}

* preHandler - Controller 진입전
* postHandler - view forward 전
* afterCompletion - view forward 및 로드 후


필요2. context 에 등록

 <bean id="annotationMapper"
  class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
  <property name="interceptors">
   <list>
    <ref bean="ExampleHandler"/>   </list>
  </property>
  <property name="order" value="1" />
 </bean>

 <bean id="ExampleHandler " class="xxx.xxx.xxx.ExampleHandler" />

 

'java > framework' 카테고리의 다른 글

Spring3 properites call  (0) 2016.02.04
jsp 에서 Spring framework 연동  (0) 2013.07.19