1、开发时Struts 2、 Hibernate、Spring需要的JAR。
struts2-core-2.x.x.jar :Struts 2框架的核心类库
xwork-2.x.x.jar :XWork类库,Struts 2在其上构建
ognl-2.6.x.jar :对象图导航语言(Object Graph NavigationLanguage),struts2框架通过其读写对象的属性
freemarker-2.3.x.jar :Struts 2的UI标签的模板使用FreeMarker编写
commons-fileupload-1.2.x.jar文件上传组件,2.1.6版本后需要加入此文件
2、 struts2-spring-plugin-2.x.x.jar:用于struts2集成Spring的插件
hibernate核心安装包下的(下载路径:http://www.hibernate.org/,点击“Hibernate Core”右边的“Downloads”):
hibernate3.jar
lib\bytecode\cglib\hibernate-cglib-repack-2.1_3.jar
lib\required\*.jar
3、hibernate注解安装包下的(下载路径:www.hibernate.org,点击“Hibernate Annotations”右边的“Downloads”):
hibernate-annotations.jar
lib\ejb3-persistence.jar、hibernate-commons-annotations.jar
4、Hibernate针对JPA的实现包(下载路径:www.hibernate.org,点击“Hibernate Entitymanager”右边的“Downloads”):
hibernate-entitymanager.jar
lib\test\log4j.jar、slf4j-log4j12.jar
MYSQL数据库驱动jar
4、实体bean配置模版.hbm.xml
<?xml version="1.0"encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mappingpackage="cn.csdn.bean">
<class name="Person" table="person">
<id name="id" >
<generator class="native"/>
</id>
<property name="name" length="10"not-null="true"/>
<property name="gender" not-null="true"length="5">
<typename="org.hibernate.type.EnumType">
<paramname="enumClass">cn.csdn.bean.Gender</param>
<!-- 12为java.sql.Types.VARCHAR常量值,即保存枚举的字面值到数据库,如果不指定type参数,保存到数据库的值为枚举的索引值(从0开始) -->
<paramname="type">12</param>
</type>
</property>
</class>
</hibernate-mapping>
5、在web容器中配置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>