- 浏览: 733200 次
- 性别:
- 来自: 重庆
文章分类
- 全部博客 (194)
- Webservice (6)
- ExtJs (2)
- Work Summary (4)
- CoreJava (51)
- Spring (10)
- EJB (5)
- struts1.x (3)
- C/C++ (5)
- DatabaseManager (19)
- Hibernate (5)
- Crytology (1)
- Web Server (5)
- Software Manager (5)
- WebUi (39)
- Web page (2)
- android (5)
- struts2 (12)
- Java 导出 Excel (1)
- Spring 与struts2 和Hibernate 4.0注解解决方安 (1)
- Dwr (1)
- maven3 (4)
- Windows (3)
- 表格头部信息不动使用Jquery 外部框架 (1)
- 软件行业动态 (1)
- mybatis (1)
- C# (3)
- MySQL (4)
最新评论
-
July01:
最近了解到一款StratoIO打印控件,功能如下:1、Html ...
LODOP插件开发 -
an52036:
u010980147 写道您的代码确实能生成条形码,但是打印出 ...
Java 条形码生成(一维条形码) -
di1984HIT:
学习了,很好~~
Ant 打包war 生成文件内容build.xml -
lhb319lhb:
如果 ajax(jquery)更新了 iframe 的 src ...
jquery 修改iframe src -
calosteward:
感谢楼主,除了一维条码,有没有相关二维码的资源呢?______ ...
Java 条形码生成(一维条形码)
Spring 与struts2 和Hibernate 4.0 + Dwr 注解解决方安
1. web.xml 注册文件
<!-- author liuqing datetime 2011-12-11 --> <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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"> <filter> <filter-name>OpenSessionInView</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>OpenSessionInView</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!--struts2 Filter--> <filter> <filter-name>struts2Filter</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <!-- modify .action is .html --> <init-param> <param-name>struts.action.extension</param-name> <param-value>htmls</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- dwr 与Spring Integrating --> <servlet> <servlet-name>dwr</servlet-name> <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <!--Spring Listenter--> <!--context-param> <param-name>contextClass</param-name> <param-value> org.springframework.web.context.support.AnnotationConfigWebApplicationContext </param-value> </context-param--> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:com/zk/website/conf/applicationContext.xml </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!-- loading TableColumn Information --> <listener> <listener-class>com.zk.website.listener.TableColumnNameListener</listener-class> </listener> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>default.jsp</welcome-file> <welcome-file>index.html</welcome-file> </welcome-file-list> </web-app>
配置spring 配置文件
<?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:dwr="http://www.directwebremoting.org/schema/spring-dwr" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd" xmlns:tx="http://www.springframework.org/schema/tx"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!--property name="location" value="classpath:jdbc.properties" /--> <property name="locations"> <list> <value>classpath:jdbc.properties</value> <value>classpath:hibernate.properties</value> </list> </property> </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}" /> <property name="jdbcUrl" value="${jdbc.url}" /> <property name="user" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.format_sql">${hibernate.format_sql}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> </props> </property> <property name="packagesToScan" value="com.zk.website.domain" /> </bean> <context:component-scan base-package="com.zk.website" /> <context:annotation-config /> <!-- 配置DWR 对象 --> <dwr:annotation-scan scanDataTransferObject="true" scanRemoteProxy="true" base-package="com.zk.website.dwr"/> <!-- 用配置文件的方法 --> <!--dwr:configuration> <dwr:convert type="bean" class="com.zk.website.dwr.Student"></dwr:convert> </dwr:configuration--> <dwr:controller id="dwrController" debug="true"></dwr:controller> </beans>
配置文件hibernate.properties
hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.show_sql=true hibernate.format_sql=true hibernate.hbm2ddl.auto=update
jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/website jdbc.username=root jdbc.password=123456
3. hibernate 类文件
package com.zk.website.domain; import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import static javax.persistence.GenerationType.IDENTITY; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; /** * * @author liuqing * @see * @version 1.0 * 2011-12-11 */ @Entity @Table(name="consultingType") public class ConsultingType implements java.io.Serializable { private static final long serialVersionUID = -1841212339564306628L; private Integer id; private String name; private Set<ProductConsulting> productConsultings = new HashSet<ProductConsulting>(0); public ConsultingType() { } @Id @GeneratedValue(strategy=IDENTITY) @Column(name="id", unique=true, nullable=false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @Column(name="name") public String getName() { return this.name; } public void setName(String name) { this.name = name; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="consultingType") public Set<ProductConsulting> getProductConsultings() { return productConsultings; } public void setProductConsultings(Set<ProductConsulting> productConsultings) { this.productConsultings = productConsultings; } }
hibentate 2)
package com.zk.website.domain;
import java.util.HashSet; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import static javax.persistence.GenerationType.IDENTITY; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; /** * * @author liuqing * @see * @version 1.0 * 2011-12-11 */ @Entity @Table(name="coporationInfoType") public class CoporationInfoType implements java.io.Serializable { private static final long serialVersionUID = 5576757129051664373L; private Integer id; private String name; private String remark; private Set<CoporationInfo> coporationInfoes = new HashSet<CoporationInfo>(0); public CoporationInfoType() { } @Id @GeneratedValue(strategy=IDENTITY) @Column(name="id", unique=true, nullable=false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @Column(name="name") public String getName() { return this.name; } public void setName(String name) { this.name = name; } @Column(name="remark") public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="coporationInfoType") public Set<CoporationInfo> getCoporationInfoes() { return coporationInfoes; } public void setCoporationInfoes(Set<CoporationInfo> coporationInfoes) { this.coporationInfoes = coporationInfoes; } }
struts2类文件
package com.zk.website.web;
import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import com.opensymphony.xwork2.ActionSupport; /** * * @author liuqing * @see 公司信息 * @version 1.0 * 2011-12-8 */ @Controller("coporationInfoAction") @Scope("prototype") public class CoporationInfoAction extends ActionSupport { private static final long serialVersionUID = 3048607397328082554L; public String coporationInfo() { return SUCCESS; } }
struts.xml 文件
<?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"> <!-- START SNIPPET: xworkSample --> <struts> <constant name="struts.i18n.reload" value="false" /> <constant name="struts.devMode" value="true" /> <package name="global" namespace="/" extends="struts-default"> <action name="index" class="indexAction"> <result name="success">/index.jsp</result> </action> <action name="" class="indexAction"> <result name="success">/index.jsp</result> </action> </package> <package name="test_1" namespace="/helloWorld" extends="global"> <action name="testAction" class="testAction" method="add"> <result name="list">/testAction/test.jsp</result> </action> </package> <package name="product_1" namespace="/productInfo" extends="global"> <action name="productInfoAction_*" class="productInfoAction" method="{1}"> <result name="success">/productInfo/productInfo_list.jsp</result> </action> </package> <package name="customer_1" namespace="/customerServer" extends="global"> <action name="customerServerAction_*" class="customerServerAction" method="{1}"> <result name="success">/customerServer/customerServer_list.jsp</result> </action> </package> <package name="findPeople_1" namespace="/findPeople" extends="global"> <action name="findPeopleAction_*" class="findPeopleAction" method="{1}"> <result name="success">/findPeople/findPeople_list.jsp</result> </action> </package> </struts>
dwr 类文件
package com.zk.website.dwr; import java.util.ArrayList; import java.util.List; import org.directwebremoting.annotations.RemoteMethod; import org.directwebremoting.annotations.RemoteProperty; import org.directwebremoting.annotations.RemoteProxy; /** * * @author liuqing * @see * @version 1.0 * 2011-12-11 */ @RemoteProxy public class DwrTest { public String test() { return "Hello World Dwr!"; } //加了个这注象后没有加的默认不能访问 @RemoteMethod public String usb() { return "usb"; } @RemoteMethod public Student usbss() { Student stu = new Student(); stu.setUsb("122431431"); return stu; } @RemoteMethod public List<Student> queryByAll() { List<Student> students = new ArrayList<Student>(); Student stu = new Student(); stu.setUsb("122431431"); Student stu1 = new Student(); stu.setUsb("122431431"); students.add(stu); students.add(stu1); return students; } protected String hellProtected() { return "helloProtected"; } private String priHello() { return "private"; } }
package com.zk.website.dwr; import java.io.Serializable; import org.directwebremoting.annotations.DataTransferObject; import org.directwebremoting.annotations.RemoteProperty; /** * * @author liuqing * @see Dwr对象测试 * @version 1.0 * 2011-12-11 */ @DataTransferObject public class Student implements Serializable{ private String usb; //同@RemoteMethod 一样 @RemoteProperty private String id; public String getUsb() { return usb; } public void setUsb(String usb) { this.usb = usb; } public String getId() { return id; } public void setId(String id) { this.id = id; } }
OK 下面有整合后lib 包可以下载的报可以下载
希望对朋友们有所帮助
发表评论
-
Spring mvc Token
2015-08-03 19:40 982request.getSession(false).s ... -
struts2 注解参数配置
2012-04-15 21:08 4206author 刘庆 @Date 2010-10-2 ... -
Spring dao 和Service 生成文件类
2012-02-13 09:23 2213package com.annotationtodaotose ... -
Struts2 下载文件文名名中文问题
2012-02-10 11:23 956作者:liuqing strut.xml 文件配置 ... -
Struts2 <s:select 标答optgroup 的使用
2012-01-10 16:49 3729<s:select name="" ... -
Struts2 获得Servlet 对象
2011-12-28 13:08 1030@author liuqing @datetime 2010 ... -
Struts2 国际化
2011-10-01 14:01 1280作者:刘庆 struts2 在这里有观原理就不做介绍了哈 ... -
Struts s:property 标签的使用
2011-09-30 14:34 52761. <s:property value=&quo ... -
Struts 2 s:set 标签的使用
2011-09-29 16:12 12141@author liuqing 1. struts2 标签 ... -
Struts2 直接输出字符 type="stream"
2011-09-28 17:10 42381. 用json 不能解决的问题 有时我们用java ... -
freemark 学习笔记
2011-08-26 12:57 1367struts2 集成的 freemark 因为我们要自定义 ... -
Struts2 自定义标签与struts2 无缝整合支技ognl 等
2011-08-26 01:49 7438author liuqing 刘庆 标签原理这里就不做详细 ... -
自定义struts2 tag
2011-08-24 17:58 1866添加Bean对象 package com. ... -
Spring jdbc 操作存储过程
2011-07-26 14:14 3855首先我们要用Spring 与 Jdbc 调用存储过程 ... -
Spring 调用jndi 数据源 struts + hibernate + spring 整合
2011-06-15 17:29 1676<?xml version="1.0" ... -
SpringSecurity 2中文文档
2011-05-26 10:46 1071有不少同事在问spring security 2 有没有中文的 ... -
Spring3.0 Struts2 Hibernate 开发精华
2010-11-29 17:20 15601. 自动添加事务管理应用声明性事务 2. 直接引用hibe ... -
Spring 自动事务管理配置文件
2010-11-29 17:16 1804/* * To change this templat ... -
acegi web.xml
2010-10-24 23:14 1129<?xml version="1.0&q ... -
在web.xml 文件下添加 OpenEntityManagerInViewFilter
2010-06-17 13:35 3583错误原因 13:34:34,859 ERROR LazyIni ...
相关推荐
公文管理、申请审批、公告管理、会议管理、权限管理、个人办公、客户管理、人事等等。项目技术:Struts1.2 + Hibernate3.0 + Spring2 +DWR。java毕业设计 jsp毕业设计 ssh毕业设计
总结,该例示注释非常详细,演示Spring托管Hibernate和Struts的Action, 以及Spring的事务声明(包括1.x与2.x的用法)与非事务声明的使用方式。 使用DWR可以方便的使用Spring托管的持久层功能。 目的:希望广大Java...
spring+struts+hibernate+jbpm+dwr整合开发的OA办公系统源码
使用struts2、hibernate、spring、dwr整合的简单项目。包括级联等 注意:csdn上面显示为chm文件。该文件为.7z的压缩文件。用压缩软件可以打开的 csdn弄错了
struts2+hibernate+spring+dwr(用户注册)struts2+hibernate+spring+dwr(用户注册)
Struts1.2+Hibernate3.0+Spring2+DWR OA 办公自动化管理系统
Struts2 + spring + hibernate + dwr 完美整合代码 dwr 用户注册 多级下拉联动 刷新表格.. 全部代码
一个struts2+spring+hibernate+dwr的小实例,不过木有搭建说明,不过有dwr的使用说明,至于表结构可以看映射配置文件就知道创建什么表了
我自己做的spring3+struts2+hibernate3+dwr3+spring security3+ajax请求+数据库配置权限 完整实例
OA 办公自动化管理系统(Struts1.2+Hibernate3.0+Spring2+DWR)
完整的struts1.2+hibernate3.2+spring2.5框架集成 完整的dwr2.0+spring2.5集成 处理的dwr2.0+hibernate3.2集成的问题
spring+struts+hibernate+dwr+jstl做的实例.rar
struts1+hibernate+dwr 项目 房屋信息发布struts1+hibernate+dwr 项目 房屋信息发布struts1+hibernate+dwr 项目 房屋信息发布
1. word文档记录了Struts2+Hibernate3+Spring2.5整合详细步骤,附有操作步骤的图示参考,并给出了各个步骤的注意事项; 2. 源代码实例包括一个完整模块的增删改查操作,可直接运行,可以在此基础上直接进行自己系统...
struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查struts1+spring+hibernate+dwr 项目 满意度调查
Struts+Hibernate+Spring+DWR实例
自己搭建的spring3+struts2+hibernate+dwr框架
struts2.2.1+spring 3.0.3+hibernate3.6+dwr3.0全注解整合包
新版SSH+DWR配置(Struts2.1.8+Spring3.0+Hibernate3.3.2+DWR2.0.6) 很好的整合示例 目前最新框架整合