ラーメンと鳥のメモ——Spring Struts 2
今日はSpring対Struts 2の集積をしました.
まずweb.xmlにspringのlistenerを配置します.
このようにSpringは容器の起動に合わせて起動できます.
そしてstrutsのactionがSpringのbeanを指すためには、struts 2-spring-plugn-XX.jarが必要です.その後、struts.xmlに設定します.
これでstrutsブロックの要求をspringに呼んで処理します.
そしてstrutsのactionのクラスにspringを指すbeanを設定することができます.
まずweb.xmlにspringのlistenerを配置します.
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/spring-config/platformContext.xml,
/WEB-INF/config/spring-config/beanContext.xml</param-value>
</context-param>
このようにSpringは容器の起動に合わせて起動できます.
そしてstrutsのactionがSpringのbeanを指すためには、struts 2-spring-plugn-XX.jarが必要です.その後、struts.xmlに設定します.
<constant name="struts.objectFactory" value="spring" />
これでstrutsブロックの要求をspringに呼んで処理します.
そしてstrutsのactionのクラスにspringを指すbeanを設定することができます.