- 浏览: 262723 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
tonytony3:
THANK YOU
Android多级树形菜单的实现 -
haiyang08101:
deleteNumber = "421f481e-7 ...
java对xml文件做增删改查 -
求求你帮帮我:
怎么把我的空格也当成节点处理了?
java对xml文件做增删改查 -
求求你帮帮我:
deleteNumber = "421f481e-7 ...
java对xml文件做增删改查 -
lpj13579:
多谢分享,学习学习
高仿小米盒子UI效果实现
1.新建Web工程
2.在classpath下建立META-INF目录,并在其中创建persistence.xml文件:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="oa" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/oa" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="root" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
3.在WEB-INF目录下建立applicationContext.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Spring上下文配置,包括jpa,dataSource,sessionFactory,Transaction等 -->
<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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置JPA注解支持-->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
</bean>
<!-- 配置实体管理器工厂 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="oa" />
</bean>
<!-- 配置基于注解的声明式事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- 使用自动扫描方式管理bean-->
<context:component-scan base-package="cn.edu.swu.oa" />
</beans>
4.在web.xml文件中配置Spring和Struts2:
<?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>oa</display-name>
<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>
<!-- 配置Spring应用上下文文件的位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<!-- 配置Spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置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>
<!-- 配置字符编码过滤器 -->
<filter>
<filter-name>encoding</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>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
5.在classpath下建立struts.xml文件,将Struts2委托Spring管理:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 将struts2委托Spring管理 -->
<constant name="struts.objectFactory" value="spring"></constant>
<package name="test" extends="struts-default">
</package>
</struts>
2.在classpath下建立META-INF目录,并在其中创建persistence.xml文件:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="oa" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/oa" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="root" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
3.在WEB-INF目录下建立applicationContext.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Spring上下文配置,包括jpa,dataSource,sessionFactory,Transaction等 -->
<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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置JPA注解支持-->
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
</bean>
<!-- 配置实体管理器工厂 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="oa" />
</bean>
<!-- 配置基于注解的声明式事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- 使用自动扫描方式管理bean-->
<context:component-scan base-package="cn.edu.swu.oa" />
</beans>
4.在web.xml文件中配置Spring和Struts2:
<?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>oa</display-name>
<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>
<!-- 配置Spring应用上下文文件的位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
<!-- 配置Spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置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>
<!-- 配置字符编码过滤器 -->
<filter>
<filter-name>encoding</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>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
5.在classpath下建立struts.xml文件,将Struts2委托Spring管理:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- 将struts2委托Spring管理 -->
<constant name="struts.objectFactory" value="spring"></constant>
<package name="test" extends="struts-default">
</package>
</struts>
发表评论
-
Android 三大图片加载框架比较
2016-11-30 10:31 10351.哪三大图片加载框架? 1) Pi ... -
Java Calendar 类的时间操作
2016-06-01 21:02 623ava Calendar 类时间操作,这也许是创建日历和管理 ... -
获取电脑ip,所在省份城市
2014-08-27 09:45 629调用了腾讯的ip接口(http://fw.qq.com ... -
获取Android签名证书的sha1值
2014-08-23 23:14 627前言:今天开始研 ... -
java中Keytool的使用总结
2014-08-23 22:40 503J2SDK提供了keytool命令行工具,可以根据指定的参数 ... -
Java基础——Java语法基础(3)
2014-06-19 10:13 534程序控制流程 1、顺序结构 按顺序执行 2、i ... -
Java基础——Java语法基础(1)
2014-06-19 10:11 758Java代码基本格式 Java ... -
android MD5校验码的生成与算法实现
2014-06-17 10:58 826在Java中,java.security.Mes ... -
java中的字符串分割函数 split
2014-06-06 15:01 640Java中的我们可以利用sp ... -
java对xml文件做增删改查
2014-06-04 20:40 1785package com.wss; import jav ... -
获取网络的json文件 Gson解析json文件
2013-11-07 16:21 486/** * 获取网络的json文件 * @pa ... -
Java获取文件类型Mime Type的各种方法
2013-09-16 15:46 1084使用 javax.activation.MimetypesF ... -
Java栈与堆
2013-06-20 22:18 8891. 栈(stack)与堆(heap)都 ... -
Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead.
2013-05-02 12:01 658解决Android requires compiler co ... -
java创建文件和目录
2013-04-25 10:30 565创建文件和目录的关键技术点如下: 1、File类的cr ... -
iava创建文件和目录
2013-04-24 19:42 749创建文件和目录的关键技术点如下: 1、File类的cr ... -
Java程序发送邮件的两种方法
2013-01-25 10:57 1832前一段时间我在博客中发表过Java接收解析邮件的程序 ... -
SharedPreferences保存数据
2013-01-24 15:09 843package com.test; import ja ... -
java 把logcat日志保存到SD里
2013-01-22 20:21 981private void saveLogcat(){ ... -
Android开发系列:查看LogCat日志
2013-01-19 13:06 3404LogCat日志 1. Window & ...
相关推荐
Struts1.3+spring2.5+JPA(hibernate) 实现的一个小示例,比较适合初学者和整合配置查询。
Struts2+Spring2.5+Hibernate3(JPA)+ExtJS3基本后台
Struts 2 + Spring 2 + JPA + hibernate + AJAX +实例, 包含依赖jar包。
一、整合开发时Hibernate、Spring需要的JAR文件。 hibernate核心安装包下的(下载路径:http://www.hibernate.org/,点击“Hibernate Core”右边的“Downloads”): hibernate3.jar lib\bycode\cglib\hibernate-...
Struts2+Spring+JPA(Hibernate)项目所需要的jar包
Struts2.1+Spring3.0+JPA1.0(Hibernate3.3实现)例子 文章分类:Java编程 本文代码是Spring2.5各种示例的综合,在此把所有框架升级到最新版本整合一下。
整合jar文件,直接下载后放到工程lib下面。这是我整理给我的中型BBS项目用的。
eclipse(struts2+spring3+hibernate3)案例附带mysql数据库
Struts+Hibernate+spring+jpa+lucene+jbpm+compass配置文件
用Struts2 + Spring + Jpa(Hibernate)搭建的web架构,全部采用注解形式 项目用maven3来管理
这是我们大二的期末考试项目,拿出来分享一下。 中型论坛系统开发 必须实现的部分: 模板化版面 ... 随机彩色防识别验证码 ... 普通用户能实现发新帖、回帖、浏览帖子,但不能修改帖子内容 管理员可创建帖子类型及子类...
这是一个基于ssh框架开发的网上订餐系统,代码很详细,还有数据库文件,使用的话请打开README.md文件,里面有详细的教程
服务器:tomcat6.0 可运行,http://localhost:8080/spring/test.do 其中spring为tomcat配置path属性值 主要用于演示他们之间如何配置
把这个里面对应的目录里面的bestbbs文件夹拷到你对应的tomcat目录下即可运行。
车辆管理系统(struts+hibernate+spring+oracle).rar 对公务用车进行档案、费用、调度、维修、安全、运行等全方位的管理和统计,以方便...
这是BlazeDS的java端工程,其中用的是flex-spring插件,并且实现了服务器主动推送消息给客户端,工程是用maven3来管理的。...另外工程中用到了Struts2 + spring + jpa的整合,其中Struts2与BlazeDS无关。
JSF+Spring+JPA以我个人看来,应该说是Struts2+Spring+Hibernate的替代解决方案。 引入JPA去取代或者说包装或者说是升级Hibernate是为了符合JAVA EE的规范,达到ORM统一的结果。下次项目用EJB也好、用TOPLINK也好、...
spring+hibernate+jpa+struts1+struts2+springmvc+jquery+freemaker 学习笔记 Compass将lucene、Spring、Hibernate三者结合
是一个基于struts2+spring+jpa架构的分页实例(带jar包和数据库脚本)还原好数据库,用MyEclipse导入工程,部署到Tomcat就可运行。注:由于资源大小限制,我去掉了spring.jar 和 hibernate3.jar 自己加上,JDK用6.0...
网上书城(Struts2+Spring+Hibernate),使用只需要加入所需jar包、数据库为小型数据库mysql。