JavaWeb框架————Spring整合三大框架(四)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Jorocco/article/details/80055965

1、三大框架整合原理
这里写图片描述
2、整合详解
2.1 导包
这里写图片描述
这里写图片描述
这里写图片描述
2.2 单独配置Spring容器(配置过程中切记配一步测一步即服务器重启测试是否报错)
applicationContext.xml(src目录下)
这里写图片描述
web.xml(WEB-INF目录下)
这里写图片描述

2.3单独配置Struts2
struts.xml(src目录下)
这里写图片描述
这里写图片描述

2.4 Spring和Struts2整合
Struts.xml(src目录下)
这里写图片描述
这里写图片描述

2.5 单独配置Hibernate
这里写图片描述

hibernate.cfg.xml
这里写图片描述
这里写图片描述
这里写图片描述

2.6 Spring整合c3p0连接池取代hibernate中的连接
这里写图片描述
这里写图片描述

2.7 Spring整合hibernate环境操作数据库
这里写图片描述
这里写图片描述
这里写图片描述

2.8 配置Spring的AOP事务
这里写图片描述
这里写图片描述
这里写图片描述

2.8 扩大session的作用范围
这里写图片描述

2.9 工程示例
2.9.1 工程目录结构
这里写图片描述

cn.ctgu.dao
UserDao.java

package cn.ctgu.dao;

import cn.ctgu.domain.User;

public interface UserDao {
    //根据登陆名称查询user对象
    User getByUserCode(String usercode);
    //保存用户
    void save(User u);
}

cn.ctgu.dao.impl
UserDaoImpl.java

package cn.ctgu.dao.impl;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import cn.ctgu.dao.UserDao;
import cn.ctgu.domain.User;

//需要为HibernateDaoSupport注入sessionFactory
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

    @Override
    public User getByUserCode(final String usercode) {
        //HQL方式
        /*return getHibernateTemplate().execute(new HibernateCallback<User>() {

            @Override
            public User doInHibernate(Session session) throws HibernateException {

                String hql="from User where user_code=?"; 
                Query query = session.createQuery(hql);
                query.setParameter(0, usercode);
                User user=(User) query.uniqueResult();
                return user;
            }
        });*/
        //Criteria方式
        DetachedCriteria dc=DetachedCriteria.forClass(User.class);
        dc.add(Restrictions.eq("user_code", usercode));
        List<User> list=(List<User>) getHibernateTemplate().findByCriteria(dc);
        if(list!=null && list.size()>0) {
            return list.get(0);
        }else {
            return null;
        }
    }

    @Override
    public void save(User u) {

        getHibernateTemplate().save(u);

    }

}

cn.ctgu.domain
Customer.java

package cn.ctgu.domain;
/*CREATE TABLE customer(
        id BIGINT(32) NOT NULL PRIMARY KEY  AUTO_INCREMENT COMMENT'客户编号(主键)',
        NAME VARCHAR(32) NOT NULL COMMENT '客户名称(公司名称)',
        source VARCHAR(32) DEFAULT NULL COMMENT '客户信息来源',
        industry VARCHAR(32)DEFAULT NULL COMMENT '客户所属行业',
        LEVEL VARCHAR(32) DEFAULT NULL COMMENT '客户级别',
        phone VARCHAR(64) DEFAULT NULL COMMENT '固定电话',
        mobile VARCHAR(16) DEFAULT NULL COMMENT '移动电话'
    );*/
public class Customer {
    private Long id;

    private String name;
    private String source;
    private String industry;
    private String level;
    private String phone;
    private String mobile;
    private String linkman;
    public String getLinkman() {
        return linkman;
    }
    public void setLinkman(String linkman) {
        this.linkman = linkman;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSource() {
        return source;
    }
    public void setSource(String source) {
        this.source = source;
    }
    public String getIndustry() {
        return industry;
    }
    public void setIndustry(String industry) {
        this.industry = industry;
    }
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Override
    public String toString() {
        return "Customer [id=" + id + ", name=" + name + "]";
    }

}

LinkMan.java

package cn.ctgu.domain;

//联系人实体
public class LinkMan {
    private Long lkm_id;
    private Character lkm_gender;
    private String lkm_name;
    private String lkm_phone;
    private String lkm_email;
    private String lkm_qq;
    private String lkm_mobile;
    private String lkm_memo;
    private String lkm_position;
    //不与数据库中的列对应,只为了接收表单参数
    private Long cust_id;
    //表达多对一的关系
    private Customer customer;

    public Long getCust_id() {
        return cust_id;
    }
    public void setCust_id(Long cust_id) {
        this.cust_id = cust_id;
    }
    public Customer getCustomer() {
        return customer;
    }
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }
    public Long getLkm_id() {
        return lkm_id;
    }
    public void setLkm_id(Long lkm_id) {
        this.lkm_id = lkm_id;
    }
    public Character getLkm_gender() {
        return lkm_gender;
    }
    public void setLkm_gender(Character lkm_gender) {
        this.lkm_gender = lkm_gender;
    }
    public String getLkm_name() {
        return lkm_name;
    }
    public void setLkm_name(String lkm_name) {
        this.lkm_name = lkm_name;
    }
    public String getLkm_phone() {
        return lkm_phone;
    }
    public void setLkm_phone(String lkm_phone) {
        this.lkm_phone = lkm_phone;
    }
    public String getLkm_email() {
        return lkm_email;
    }
    public void setLkm_email(String lkm_email) {
        this.lkm_email = lkm_email;
    }
    public String getLkm_qq() {
        return lkm_qq;
    }
    public void setLkm_qq(String lkm_qq) {
        this.lkm_qq = lkm_qq;
    }
    public String getLkm_mobile() {
        return lkm_mobile;
    }
    public void setLkm_mobile(String lkm_mobile) {
        this.lkm_mobile = lkm_mobile;
    }
    public String getLkm_memo() {
        return lkm_memo;
    }
    public void setLkm_memo(String lkm_memo) {
        this.lkm_memo = lkm_memo;
    }
    public String getLkm_position() {
        return lkm_position;
    }
    public void setLkm_position(String lkm_position) {
        this.lkm_position = lkm_position;
    }

}

User.java

package cn.ctgu.domain;

import java.util.HashSet;
import java.util.Set;

public class User {
    private Long user_id;
    private String user_code;
    private String user_name;
    private String user_password;
    private Character user_state;

    public Long getUser_id() {
        return user_id;
    }
    public void setUser_id(Long user_id) {
        this.user_id = user_id;
    }
    public String getUser_code() {
        return user_code;
    }
    public void setUser_code(String user_code) {
        this.user_code = user_code;
    }
    public String getUser_name() {
        return user_name;
    }
    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }
    public String getUser_password() {
        return user_password;
    }
    public void setUser_password(String user_password) {
        this.user_password = user_password;
    }
    public Character getUser_state() {
        return user_state;
    }
    public void setUser_state(Character user_state) {
        this.user_state = user_state;
    }
    @Override
    public String toString() {
        return "User [user_id=" + user_id + ", user_code=" + user_code + ", user_name=" + user_name + ", user_password="
                + user_password + "]";
    }


}

Customer.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--配置表与实体对象的关系  -->
<!-- package属性:填写一个包名,在元素内部凡是需要书写完整类名的属性,可以直接写简单类名 -->
<hibernate-mapping package="cn.ctgu.domain">
    <!-- 
        Class元素:配置实体与表的对应关系
            name:完整类名
            table:数据库表名
     -->
    <class name="Customer" table="customer">
        <!-- 
            id元素:配置主键映射的属性
                name:填写主键对应实体中的属性名
                column:填写表中的主键列名
                column(可选):填写表中对应属性的列名
                    type(可选):填写列(属性)的类型,不写的话hibernate会自动检测实体的属性类型
                        有三种写法:java类型   hibernate类型  sql类型
                        java.lang.String     string    varchar
                    not-null(可选):配置该属性(列)是否为空,默认值:false
                    length(可选):配置数据库中列的长度,默认值:使用数据库类型的最大长度(varchar最大长度为255)
         -->
        <id name="id"  column="id">
            <!-- generator:主键生成策略 -->
            <generator class="native"></generator>
        </id>
            <!-- property元素:出id之外的普通属性映射
                    name:填写属性名

                    column(可选):填写表中对应属性的列名,默认值:列名为属性名
                    type(可选):填写列(属性)的类型,不写的话hibernate会自动检测实体的属性类型
                        有三种写法:java类型   hibernate类型  sql类型
                        java.lang.String     string    varchar
                    not-null(可选):配置该属性(列)是否为空,默认值:false
                    length(可选):配置数据库中列的长度,默认值:使用数据库类型的最大长度(varchar最大长度为255)
             -->
        <!-- <property name="name" column="NAME" type="" not-null="" length=""></property>-->
        <property name="name" column="NAME" ></property>
        <property name="source" column="source"></property>
        <property name="industry" column="industry"></property>
        <property name="level" column="LEVEL"></property>
        <property name="phone" column="phone"></property>
        <property name="mobile" column="mobile"></property>
        <property name="linkman" column="linkman"></property>
    </class>
</hibernate-mapping>

LinkMan.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping package="cn.ctgu.domain">
    <class name="LinkMan" table="link_man">
        <id name="lkm_id" >
            <generator class="native"></generator>
        </id>
        <property name="lkm_name" ></property>
        <property name="lkm_phone" ></property>
        <property name="lkm_email" ></property>
        <property name="lkm_qq" ></property>
        <property name="lkm_mobile" ></property>
        <property name="lkm_memo" ></property>
        <property name="lkm_position" ></property>
        <property name="lkm_gender" ></property>

        <!-- 多对一
            name属性:引用属性名
            column属性:外键列名
            class属性:与我关联的对象完整类名
         -->
         <!-- 级联操作
            级联操作:cascade
                save-update:级联保存更新,即在保存customer的同时将linkman也保存(session.save(c))至数据库,更加便捷
                delete:级联删除
                all:save-update+delete
            级联操作:简化操作
          -->
          <!--<many-to-one name="customer" column="lkm_cust_id" class="Customer" cascade="save-update"></many-to-one>-->
         <!-- 多的一方:不能放弃维护关系的,因为外键在多的一方,所有不能放弃它的维护,只能一的一方(Customer)可以放弃维护-->
         <many-to-one name="customer" column="lkm_cust_id" class="Customer"></many-to-one>
    </class>
</hibernate-mapping>

User.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping package="cn.ctgu.domain">
    <class name="User" table="user">
        <id name="user_id"  column="id">
            <generator class="native"></generator>
        </id>
        <property name="user_name"></property>
        <property name="user_code" ></property>
        <property name="user_password"></property>
        <property name="user_state" ></property>



    </class>
</hibernate-mapping>

cn.ctgu.service
UserService.java

package cn.ctgu.service;

import cn.ctgu.domain.User;

public interface UserService {
    //登陆方法
    User getUserByCodePassword(User u);
    //注册用户
    void saveUser(User u);
}

cn.ctgu.service.impl
UserServiceImpl.java

package cn.ctgu.service.impl;

import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.ctgu.dao.UserDao;
import cn.ctgu.domain.User;
import cn.ctgu.service.UserService;

@Transactional(isolation=Isolation.REPEATABLE_READ,propagation=Propagation.REQUIRED,readOnly=true)
public class UserServiceImpl implements UserService{

    private UserDao ud;
    @Override
    public User getUserByCodePassword(User u) {
        //1、根据登陆名称查询登陆用户
        User existU=ud.getByUserCode(u.getUser_code());
        //2、判断用户是否存在,不存在=》抛出异常,提示用户名不存在
        if(existU==null) {
            throw new RuntimeException("用户名不存在!");
        }
        //3、判断用户密码是否正确=》不正确=》抛出异常,提示密码错误
        if(!existU.getUser_password().equals(u.getUser_password())) {
            throw new RuntimeException("密码错误!");
        }
        //4、返回查询到的用户对象


        return existU;
    }

    @Override
    @Transactional(isolation=Isolation.REPEATABLE_READ,propagation=Propagation.REQUIRED,readOnly=false)
    public void saveUser(User u) {
        // TODO Auto-generated method stub
        ud.save(u);
    }

    public void setUd(UserDao ud) {
        this.ud = ud;
    }

}

cn.ctgu.web.action
UserAction.java

package cn.ctgu.web.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import cn.ctgu.domain.User;
import cn.ctgu.service.UserService;

public class UserAction extends ActionSupport implements ModelDriven<User>{

    private User user=new User();

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public String login() throws Exception {

        //1、调用Service执行登陆逻辑
        User u=userService.getUserByCodePassword(user);

        //2、将返回的User对象放入session域
        ActionContext.getContext().getSession().put("user", u);

        //3、重定向到项目首页

        return "toHome";
    }

    @Override
    public User getModel() {

        return user;
    }



}

配置文件
applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans" 
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop" 
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd 
                            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd 
                            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd 
                            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
    <!-- 读取db.properties文件 -->
    <context:property-placeholder location="classpath:db.properties"/>
    <!--引入c3p0连接池  -->
    <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
        <property name="driverClass" value="${jdbc.driverClass}"></property>
        <property name="user" value="${jdbc.user}"></property>
        <property name="password" value="${jdbc.password}"></property>
    </bean>

    <!--=====================================================  -->
    <!-- 配置事务,核心事务管理器 -->
    <bean name="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!--配置通知  -->
    <!-- <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        通配符配置文件,只要是以save开头的服务都配置成该样 
        以方法为单位,指定方法应用什么事务属性
        isolation:隔离级别
        propagation:传播行为
        read-only:是否只读


        <tx:method name="save*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="persist*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="update*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="modify*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="delete*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="remove*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
        <tx:method name="get*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>
        <tx:method name="find*" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="true"/>

    </tx:attributes>
</tx:advice> -->

<!-- 配置将通知织入目标对象 -->
<!-- <aop:config>
    配置切点表达式
    <aop:pointcut expression="execution(* cn.ctgu.service.impl.*ServiceImpl.*(..))" id="txPc"/>
    配置切面=>通知+切入点 
        advice-ref:通知的名称
        pointcut-ref:切点的名称

    <aop:advisor advice-ref="txAdvice" pointcut-ref="txPc"/>
</aop:config> -->

<!--==============================================  -->
<!-- 使用注解方式进行aop事务配置 -->
<!-- 开启注解事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>


<!--==================================================  -->
    <!-- 将SessionFactory配置到spring容器中 -->
    <!--加载配置方案1:仍然使用外部的hibernate.cfg.xml配置信息  -->
    <!--加载配置方案2:在spring配置中放置hibernate配置信息  -->
    <!-- <bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" >
        方案1
        <property name="configLocation" value="classpath:hibernate.cfg.xml" ></property>
    </bean> -->

    <bean name="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" >
        <!-- 方案2 -->
        <!-- 将连接池 注入到sessionFactory,hibernate会通过连接池获得连接-->
        <property name="dataSource" ref="dataSource"></property>
        <!-- 配置基本信息 -->
        <property name="hibernateProperties">
            <props>
                <!-- 必选配置(使用c3p0连接池取代下面的)  -->
                <!-- <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
                <prop key="hibernate.connection.url">jdbc:mysql:///hibernate</prop>
                <prop key="hibernate.connection.username">root</prop>
                <prop key="hibernate.connection.password">123456</prop> -->
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>

                <!-- 可选配置 -->
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
        <!-- 引入orm元数据,指定orm元数据所在的包路径,spring会自动读取包中的所有配置信息 -->
        <property name="mappingDirectoryLocations" value="classpath:cn/ctgu/domain"></property>

    </bean>


<!--================================================-->
    <!-- action配置 -->
    <!-- 注意:Action对象作用范围一定是多例的,这样才符合struts2架构 -->
    <bean name="userAction" class="cn.ctgu.web.action.UserAction" scope="prototype">
        <!--手动组装依赖属性  -->
        <property name="userService" ref="userService"></property>
    </bean>

    <!-- service配置 -->
    <bean name="userService" class="cn.ctgu.service.impl.UserServiceImpl">
        <property name="ud" ref="userDao"></property>
    </bean>

    <!-- dao配置 -->
    <bean name="userDao" class="cn.ctgu.dao.impl.UserDaoImpl">
        <!-- 注入sessionFactory -->
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

</beans>

hibernate.cfg.cml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
         <!-- 数据库驱动 -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
         <!-- 数据库url -->
        <property name="hibernate.connection.url">jdbc:mysql:///hibernate</property>
         <!-- 数据库连接用户名 -->
        <property name="hibernate.connection.username">root</property>
         <!-- 数据库连接密码 -->
        <property name="hibernate.connection.password">123456</property>
        <!-- 数据库方言
            注意: MYSQL在选择方言时,请选择最短的方言.
         -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>


        <!-- 将hibernate生成的sql语句打印到控制台 -->
        <property name="hibernate.show_sql">true</property>
        <!-- 将hibernate生成的sql语句格式化(语法缩进) -->
        <property name="hibernate.format_sql">true</property>
        <!-- 
        自动导出表结构. 自动建表
         -->
        <property name="hibernate.hbm2ddl.auto">update</property>

        <mapping resource="cn/ctgu/domain/Customer.hbm.xml"/>
        <mapping resource="cn/ctgu/domain/LinkMan.hbm.xml"/>
        <mapping resource="cn/ctgu/domain/User.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

struts.xml

<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <!--配置常量  -->
    <!-- # struts.objectFactory = spring 将action的创建交给sping容器
    struts.objectFactory.spring.autoWire = name  sping负责装配action的依赖属性
    -->
    <constant name="struts.objectFactory" value="spring"></constant>

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

        <global-exception-mappings>
            <exception-mapping result="error" exception="java.lang.RuntimeException"></exception-mapping>
        </global-exception-mappings>

        <!--整合方案1:class属性仍然配置action的完整类名
            struts2仍然创建action,由spring负责组装Action中的依赖属性(例如:UserService)
            <action name="UserAction_*" class="cn.ctgu.web.action.UserAction" method="{1}">
            <result name="success">/success.jsp</result>
        </action>
         -->
         <!-- 整合方案2:class属性为applicationContext.xml中action对象的bean name 
                完全由spring管理action生命周期,包括Action的创建
                注意:需要手动组装依赖属性
         -->
        <action name="UserAction_*" class="userAction" method="{1}">
            <result name="toHome" type="redirect">/index.htm</result>
            <result name="error">/login.jsp</result>
        </action>
    </package>
</struts>   

db.properties

jdbc.jdbcUrl=jdbc:mysql:///hibernate
jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=123456

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Spring4</display-name>

  <!--让spring随web启动而创建的监听器  -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!--配置spring配置文件位置参数  -->
   <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
<!--====================================================  -->
 <!--扩大session作用范围
    注意:任何filter一定要在struts的filter之前调用
    因为struts的filter没有放行
   -->
 <filter>
    <filter-name>openSessionInView</filter-name>
    <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>openSessionInView</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


 <!-- 配置struts2核心过滤器 -->
  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>




  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>
阅读更多
换一批

没有更多推荐了,返回首页