ssh基础配置大全

firstweb

firstweb-pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--说明pom的版本-->
  <modelVersion>4.0.0</modelVersion>
<!--说明项目和公司名-->
  <groupId>xxxxxx</groupId>
<!--说明项目的子模块名-->
  <artifactId>xxx</artifactId>
<!--说明打包的方式,常见的jar和war-->
  <packaging>war</packaging>
<!--说明版本-->
  <version>0.0.1-SNAPSHOT</version>
  <name>xxx Maven Webapp</name>
  <url>http://maven.apache.org</url>
<!--依赖的jar包-->
  <dependencies>
<!--jsp项目必需的依赖 servlet-->
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.0-b07</version>
<!--provided说明只在编译和测试中有效-->
    <scope>provided</scope>
   <!-- 只在编译时和测试时运行 -->
</dependency>
<!--Junit测试依赖-->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
<!--test作用于测试的时候-->
      <scope>test</scope>
    </dependency>
  </dependencies>
    <build>    
        <finalName>xxx</finalName>
     <plugins>
      <plugin>
<!--tomcat服务器依赖-->
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
          <executions>
          <execution>
          <phase>package</phase>
          <goals>
<!--在package的时候运行-->
          <goal>run</goal>
          </goals>
          </execution>
          </executions>
        </plugin>
     </plugins> 
    </build>
</project>

hibernate

hibernate-pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.hibernate</groupId>
  <artifactId>xml_onetomany</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>xml_onetomany Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.26</version>
</dependency>
  
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-osgi</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-envers</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-proxool</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-infinispan</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<!--二级缓存依赖-->
 <dependency>
           <groupId>net.sf.ehcache</groupId>
           <artifactId>ehcache-core</artifactId>
           <version>2.4.3</version>
        </dependency>
<!--hibernate二级缓存插件-->
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-ehcache</artifactId>
    <version>5.2.10.Final</version>
</dependency>
<!--hibernate注释依赖-->
<dependency>
    <groupId>org.hibernate.common</groupId>
    <artifactId>hibernate-commons-annotations</artifactId>
    <version>5.0.1.Final</version>
</dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
    <build>    
        <finalName>xml_onetomany</finalName>
    </build>
</project>

 hibernate-hibernate.cfg.xml

<?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="connection.username">root</property>
        <property name="connection.password">xxx</property>
        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="connection.url">jdbc:mysql://localhost:3306/hibernate_demo</property>
<!--选择数据库方言-->        
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!--是否在console输出sql语句-->
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
<!--update用于更新数据库表,常见create:如果数据库存在该表先删除再重建-->
        <property name="hbm2ddl.auto">update</property>
        <mapping resource="Students.hbm.xml" />
    </session-factory>
</hibernate-configuration>

hibernate-ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">     
<!--user.home – 用户主目录
user.dir      – 用户当前工作目录
java.io.tmpdir – 默认临时文件路径 -->  
    <diskStore path="java.io.tmpdir " />   
    <defaultCache  
            maxElementsInMemory="3000"  
            eternal="false"
            timeToIdleSeconds="3600"  
            timeToLiveSeconds="3600"  
            overflowToDisk="true"  
            />
            <cache name="second_ehcache.Students"
            maxElementsInMemory="3000"  
            eternal="false"
            timeToIdleSeconds="360"  
            timeToLiveSeconds="360"  
            overflowToDisk="true"  
            />
            </ehcache>
<!--   1.maxElementsInMemory:对象的最大储存个数
         2.eternal:是否永久储存
         3.overflowToDisk:超过最大储存数,是否储存在磁盘
         4.memoryStoreEvictionPolicy内存中的对象置换策略,例如FIFO,LRU,LFU
 -->
<!--
    1、timeToLiveSeconds的定义是:以创建时间为基准开始计算的超时时长;
    2、timeToIdleSeconds的定义是:在创建时间和最近访问时间中取出离现在最近的时间作为基准计算的超时时长;
    3、如果仅设置了timeToLiveSeconds,则该对象的超时时间=创建时间+timeToLiveSeconds,假设为A;
    4、如果没设置timeToLiveSeconds,则该对象的超时时间=max(创建时间,最近访问时间)+timeToIdleSeconds,假设为B;
    5、如果两者都设置了,则取出A、B最少的值,即min(A,B),表示只要有一个超时成立即算超时。

  -->

struts2

struts2-pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.struts</groupId>
  <artifactId>first</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>first Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency><!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
<!-- struts依赖 -->
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.5.5</version>
</dependency>
<!-- servlet依赖,即jsp必备 -->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>
</dependencies>
  <build>
    <finalName>first</finalName>
  </build>
</project>

 struts2-struts2.xml

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd" >
<struts>
    <!-- include节点是struts2中组件化的方式 可以将每个功能模块独立到一个xml配置文件中 然后用include节点引用,常见的有struts.properties:
struts.properties中文件的配置参数
#指定默认的编码集,对于请求参数有中文的情况下应该设置成GBK或者GB2312,默认值UTF-8
struts.i18n.encoding=GB2312
#是否每次HTTP请求到达时,都重新加载国际化资源文件,默认值false
struts.i18n.reload=true
#在struts.xml改动以后,是否重新加载该文件,开发阶段建议设置为true,默认为false
struts.configuration.xml.reload=true
#是否使用struts2的开发模式,可以获得更多报错信息,便于调试
struts.devMode=true
#设置浏览器是否缓存静态页面,开发阶段设置为false,默认值为true
struts.serve.static.browserCache=true
#指定后缀为.action形式的请求,可被struts2处理,可配置多个
struts.action.extension=action,do,struts2, -->
    <include file="struts-default.xml"></include>    
    <!-- package提供了将多个Action组织为一个模块的方式
        package的名字必须是唯一的 package可以扩展 当一个package扩展自
        另一个package时该package会在本身配置的基础上加入扩展的package
        的配置 父package必须在子package前配置 
        name:package名称
        extends:继承的父package名称
        abstract:设置package的属性为抽象的 抽象的package不能定义action 值true:false
        namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action
     -->
    <package name="com.kay.struts2" extends="struts-default" namespace="/test">
        <interceptors>
            <!-- 定义拦截器 
                name:拦截器名称
                class:拦截器类路径
             -->
            <interceptor name="timer" class="com.kay.timer"></interceptor>
            <interceptor name="logger" class="com.kay.logger"></interceptor>
            <!-- 定义拦截器栈 -->
            <interceptor-stack name="mystack">
                <interceptor-ref name="timer"></interceptor-ref>
                <interceptor-ref name="logger"></interceptor-ref>
            </interceptor-stack>
        </interceptors> 
        <!-- 定义默认的拦截器 每个Action都会自动引用
         如果Action中引用了其它的拦截器 默认的拦截器将无效 -->
        <default-interceptor-ref name="mystack"></default-interceptor-ref>

        <!-- 全局results配置 -->
        <global-results>
            <result name="input">/error.jsp</result>
        </global-results>    
        <!-- Action配置 一个Action可以被多次映射(只要action配置中的name不同)
             name:action名称
             class: 对应的类的路径
             method: 调用Action中的方法名
        -->
        <action name="hello" class="com.kay.struts2.Action.LoginAction">
            <!-- 引用拦截器
                name:拦截器名称或拦截器栈名称
             -->
            <interceptor-ref name="timer"></interceptor-ref>
            <!-- 节点配置
                name : result名称 和Action中返回的值相同
                type : result类型 不写则选用superpackage的type struts-default.xml中的默认为dispatcher
             -->
         <result name="success" type="dispatcher">/talk.jsp</result>
         <!-- 参数设置 
             name:对应Action中的get/set方法 
         -->
         <param name="url">http://www.sina.com</param>
        </action>
    </package>
</struts>

 

 spring

spring-pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.spring</groupId>
  <artifactId>annonation_spring_aop</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>first_spring Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>4.3.10.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.3.10.RELEASE</version>
</dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.8.10</version>
</dependency>
    <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
</dependency> 
     <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
<!--test作用于测试的时候-->
      <scope>test</scope>
      </dependency>
  </dependencies>
 <build>    
        <finalName>annonation_spring_aop</finalName>
    </build>
</project>

 spring-applicationContext.xml(bean:注释,aspect:注释)

<?xml version="1.0" encoding="UTF-8"?>  
<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"  
         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.1.xsd  
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd  
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">  
         <!--注释方式扫描bean-->
         <context:annotation-config/>
        <!-- 对以manager开头的包进行扫描 -->
        <context:component-scan base-package="manager"/>
    <!-- 启用Spring对基于@AspectJ aspects的注释支持 -->  
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>  
</beans>

spring-applicationContext.xml(bean:注释,aspect:xml)

<?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:context="http://www.springframework.org/schema/context"
     xmlns:aop="http://www.springframework.org/schema/aop"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-4.1.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-4.1.xsd">    
     
        <!-- 通过annotation来进行bean的创建 -->
        <context:annotation-config/>
        <!-- 对以manager开头的包进行扫描 -->
        <context:component-scan base-package="manager"/>
        <!-- 通过xml方式来配置AOP -->
        <aop:config>       
            <!-- 声明在哪些位置我要加入这个切面 -->
             <aop:pointcut expression="execution(* find*(..))" id="testpointcut"/>
              <!-- 声明一个切面 -->                      
            <aop:aspect id="AspectJAdvice" ref="aspectJAdvice">
                <aop:before method="doBefore" pointcut-ref="testpointcut"/>
                 <aop:after method="doAfter" pointcut-ref="testpointcut"/>
                  <aop:around method="doAround" pointcut-ref="testpointcut"/>
                  <!--一定要有return属性-->
                 <aop:after-returning method="doReturn" returning="retVal" pointcut-ref="testpointcut"/>
                  <!--一定要有throwing属性-->   
              <aop:after-throwing throwing="ex" method="doThrowing" pointcut-ref="testpointcut"/>           
            </aop:aspect>
        </aop:config>        
</beans>

 

spring-applicationContext.xml(bean:xml,aspect:注释)

<?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"  
         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.1.xsd  
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd  
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
           http://www.springframework.org/schema/context">  
  
    <!-- 启用Spring对基于@AspectJ aspects的注释支持 -->  
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>  
   <bean id="xxx"  class="xxx"></bean>  
</beans>

 

spring-applicationContext.xml(ssh)

<?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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
 <!-- action的bean ,注意scope=“prototype”-->
<bean id="productAction" class="com.maven.ssh.action.ProductAction" scope="prototype">
<property name="productService" ref="productService"></property>
</bean>
<!-- service的bean -->
<bean id="productService" class="com.maven.ssh.service.ProductServiceImpl">
<property name="productDAO" ref="productDAOImpl"></property>
</bean>
<!-- dao的bean -->
<bean id="productDAO" class="com.maven.ssh.dao.ProductDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"></property>
</bean>
<!--注入datasource-->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/ssh"/>
        <property name="username" value="root"/>
        <property name="password" value="040209"/>
    </bean>
<!--注入SessionFactory-->
    <bean id="mySessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
        <property name="dataSource" ref="myDataSource"/>
        <property name="mappingResources">
            <list>
                <value>Product.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
        <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
        </property>    
    </bean>
<!--注入transactionManager-->
     <bean id="transactionManager"   class="org.springframework.orm.hibernate5.HibernateTransactionManager">
        <property name="sessionFactory" ref="mySessionFactory"/>
    </bean>
 <!--进行声明式事务管理(注释)必备配置,虽然运用了aop,但是@trsansactonal单独看成一种事务管理技术,因此下述配置不同于aop注释声明-->
           <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

 SSH

ssh之pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.project</groupId>
  <artifactId>workerManage_SSH</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>workerManage_SSH Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>5.2.10.Final</version>
</dependency>
   <dependency>
    <groupId>commons-dbcp</groupId>
    <artifactId>commons-dbcp</artifactId>
    <version>1.4</version>
</dependency> 

  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.0-b07</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-core</artifactId>
    <version>2.5.5</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>4.3.8.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin -->
<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-spring-plugin</artifactId>
    <version>2.5.12</version>
</dependency>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.26</version>
</dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.3.10.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.8.10</version>
</dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.3.0.RELEASE</version>
</dependency>
  </dependencies>
  <build>
    <finalName>workerManage_SSH</finalName>
  </build>
</project>

 ssh之web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>Archetype Created Web Application</display-name>
    <!-- spring框架的核心监听器 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <!-- struts框架的核心过滤器的配置 -->
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

 springMVC

springMVC-pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.maven.springMVC</groupId>
  <artifactId>springMVC_first</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>springMVC_first Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
   <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.0-b07</version>
<!--provided说明只在编译和测试中有效-->
    <scope>provided</scope>
   <!-- 只在编译时和测试时运行 -->
</dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/org.springframework.web.servlet -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.web.servlet</artifactId>
    <version>3.2.5.RELEASE</version>
</dependency><!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot</artifactId>
    <version>2.0.0.M3</version>
</dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.3.10.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>springMVC_first</finalName>
     <plugins>
      <plugin>
<!--tomcat服务器依赖-->
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
          <executions>
          <execution>
          <phase>package</phase>
          <goals>
<!--在package的时候运行-->
          <goal>run</goal>
          </goals>
          </execution>
          </executions>
        </plugin>
     </plugins> 
  </build>
</project>

springMVC-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <servlet>
        <servlet-name>springMVC</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
<!--在服务器启动的时候就加载这个servlet-->
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springMVC</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
</web-app>

 

学习过程中积累的xml各种配置,整理一下方便查找,之后遇到继续补充

posted @ 2017-07-26 18:08  unbelievableme  阅读(2170)  评论(0编辑  收藏  举报