Many of you will shake your head at the word "frame" and the word "reject" will come to your mind. I am no exception, but I want to tell you that when you really master it, you will find that **SSH** is so handy because it is so handy for web application development. Here is my personal experience and everyone talk about how to use the **SSH framework technology ** to ** Web application development **.

The first thing you should know is how the SSH framework technology works

Here I introduce you to a common SSH development pattern, which should be easy for beginners to understand. When using SSH framework best first to know about the working principle of the struts 2 + hibernate, here are two links, you can know about the works: “SH” [principle] struts 2 http://www.cnblogs.com/langti… [principle] hibernate https://zhidao.baidu.com/ques…

Another is SSH framework to develop the required jar package, this is very important for development, not a complete correct jar package is absolutely can’t use SSH framework, the following is my finishing the complete jar package: link: http://pan.baidu.com/s/1bFujh0 password: pisr

Outside is a process of using SSH framework technology to develop:

  1. [1] The Struts2 core filter is configured to block some actions. The core code is as follows:

    <! - struts 2 core filter configuration - > the < filter > < filter - name > struts 2 < / 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> [2] Configure the Spring core listener <! - the core of spring listener configuration - > < 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>

  1. To create the packages needed in the development process, in my example project I created four packages, respectively: [1] CN.imooc. Domain manages the package of the entity class [2] CN.imooc. Servie manages the package of the service class [3] CN.imooc
  2. Four commonly used configuration files are introduced, namely ApplicationContext.xml struts.xml log4j.properties jdbc.properties
  3. Create the required classes in each package
  4. Complete the SSH framework flow in each class
  5. Complete the corresponding configuration in the above four configuration files. Here I will only explain what functions each configuration file completes: Jdbc.properties: This is a configuration file that sets up our connection to the database, which contains the database driver, the address of the data connection, the user name of the database, XML: This file is our logging file ApplicationContext.xml: This file is the core configuration file of Spring. It is also the core of our entire SSH framework development and acts as the glue that holds Struts2 and Hibernate together.

    The configuration of the fourth file is highlighted here:

    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd ">

    < context: the property – placeholder location = “classpath: JDBC. Properties” / >

    <! Configure c3p0 connection pool –>

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClass}"></property> <property name="jdbcUrl" value="${jdbc.url}"></property> <property name="user" Value ="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> : To connect to the database we need to connect to <! - configure hibernate some relevant properties - > < bean id = "sessionFactory" class = "org. Springframework. Orm. Hibernate3. LocalSessionFactoryBean" > <! > <property name="dataSource" REF ="dataSource"/> <! > <property name=" HibernateProperties "> <props> <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> This part is to complete the Hibernate framework object mapping file function <! - loading in the hibernate mapping file - > < property name = "mappingResources" > < list > < value > cn/imooc/domain/Product. HBM. XML value > < / </list> </property> </bean>

    < bean id = “productAction” class = “cn. Imooc. Action. ProductAction” scope = “prototype” >

    <! >< property name="productService" ref="productService"></property>

    < bean id = “productService” class = “cn. Imooc. Service. ProductService” >

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

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

    </bean>

    < bean id = “transactionManager” class = “org. Springframework. Orm. Hibernate3. HibernateTransactionManager” >

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

    </bean>

    — open annotation transactions –>

That is roughly the development process of SSH framework, we have a problem can be put out to discuss, I will send you my whole project see below: link: http://pan.baidu.com/s/1jHM5wWY password: ykm9