日期:2014-05-16  浏览次数:20343 次

Hibernate+Spring+Struts2+ExtJS开发CRUD功能

http://blog.csdn.net/myloon/archive/2007/11/08/1873652.aspx-----多谢这么好的文章

Hibernate+Spring+Struts2+ExtJS开发CRUD功能
1、  入门:
各种开源框架环境及下载:
Hibernate:3.x  http://www.hibernate.org/ 需要hibernate core 和annotations 包。
Spring:2.x http://springframework.org/
Struts2:2.x http://struts.apache.org/2.x/
ExtJS:2.X http://extjs.com/
JSON:JSON可以到http://www.json.org/ 查看详细内容,这里使用json-lib http://json-lib.sourceforge.net/
本所需要的包:

2、  配置:
(1)首先是配置web.xml,配置方法可以在下面的配置文件代码注释中查看,这里主要是Struts2的配置:
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping>
和Spring的配置:
    <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/spring/*.xml</param-value>
</context-param>
    <listener>     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Web.xml的全部文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
    <display-name>struts2</display-name>
    <!-- Spring ApplicationContext配置文件的路径,可使用通配符*,多个路径用,号分隔,此参数用于后面的Spring-Context loader -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/*.xml</param-value>  
    </context-param>
    <!-- 著名 Character Encoding filter -->
    <filter>
        <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
    </filter>

    <!-- struts2 滤镜配置  -->
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--Spring ApplicationContext 载入 ,必须-->
 &n