67,538
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd ">
<bean name="/login" class="com.maesinfo.action.UserLevelAction">
<property name="userservice">
<ref bean="userservice" />
</property>
</bean>
<bean id="userservice"
class="com.maesinfo.service.UserServiceImpl">
<property name="userleveldao">
<ref bean="userleveldao" />
</property>
<property name="userdao">
<ref bean="userdao" />
</property>
</bean>
<bean id="userleveldao" class="com.maesinfo.dao.UserlevelDAO" />
<bean id="userdao" class="com.maesinfo.dao.UserDAO" />
<bean id="checkUser" class="com.maesinfo.util.CheckUserLevel" />
<aop:config>
<aop:pointcut id="allcheckmothod" expression="execution(* com.maesinfo.service.UserService.check*(..))"/>
<aop:aspect id="checkuser" ref="checkUser">
<aop:before method="checkLevel" pointcut-ref="allcheckmothod"/>
</aop:aspect>
</aop:config>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<action-mappings>
<action path="/login"
parameter="login"
type="org.springframework.web.struts.DelegatingActionProxy"
scope="request">
<forward name="success" path="/index.jsp"/>
</action>
</action-mappings>
<message-resources
parameter="com.yourcompany.struts.ApplicationResources" />
<!--
spring与struts整合:把struts的Action托管给spring
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="classpath:applicationContext.xml"/>
</plug-in>
-->
</struts-config>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="classpath:applicationContext.xml"/>
</plug-in>
......
/**
* Struts 1.1+ PlugIn that loads a Spring application context for the Struts
* ActionServlet. This context will automatically refer to the root
* WebApplicationContext (loaded by ContextLoaderListener/Servlet) as parent.
......
*/
public class ContextLoaderPlugIn implements PlugIn {
......
public final void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
......
try {
this.webApplicationContext = initWebApplicationContext();//调用initWebApplicationContext方法
onInit();
}
......
}
}<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>