天天看点

spring整合struts2配置

bean配置;

    <!-- 配置c3p0连接池 -->

    <!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

        set方法住人

        <property name="driverClass" value="com.mysql.jdbc.Driver"></property>

        <property name="jdbcUrl" value="jdbc:mysql:///spring_day03"></property>

        <property name="user" value="root"></property>

        <property name="password" value="root"></property>

    </bean> -->

    <!-- 配置action -->

    <bean id="userAction" class="cn.itcast.action.UserAction" scope="prototype">

        <property name="userService" ref="userService"></property>

    </bean>

    <!-- 创建service和dao对象 -->

    <bean id="userService" class="cn.itcast.service.UserService">

        <property name="userDao" ref="userDao"></property>

    </bean>

    <bean id="userDao" class="cn.itcast.dao.UserDao"></bean>

struts2配置:

    <package name="demo" extends="struts-default" namespace="/">

        <action name="user_*" class="userAction" method="{1}">

            <!-- 注册 -->

            <result name="register">/login.jsp</result>

            <!-- 登录 -->

            <result name="loginsuccess">/index.htm</result>

            <result name="login">/login.jsp</result>

        </action>

  </package>