`

Dwr + struts2.0 + spring + jpa

    博客分类:
  • Dwr
阅读更多

1. 重要一点是如果用了Dwr,就不能用Spring的注入了。这点要注意:

public class RatingAction extends AbstractAction{
	
	private double avg_rating ;
	
	private static IRatingService getRatingService() {
		ControllerFactory cf = ControllerFactory.getInstance();
		return (IRatingService) cf.getBean("ratingService");
	}
		
	public void addRatingActor(long userId,double rating,long actorId){
		Related related = new Related();
		related.setType(Related.TYPE_RATING_ACTOR);
		related.setObj1(userId);
		related.setObj2(actorId);
		related.setDegree(rating);
		related.setCreated(new Date());
		related.setModified(new Date());
		getRatingService().addRating(related);
	}

 2.ControllerFactory.java

import cn.ctit.titanmen.util.SpringContextPublisher;

public class ControllerFactory extends SpringContextPublisher{
	
	private static ControllerFactory controllerFactory;
	
	public static ControllerFactory getInstance(){
		if(controllerFactory==null){
			controllerFactory=new ControllerFactory();
		}
		return controllerFactory;
	}
}

 3. SpringContextPublisher.java

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringContextPublisher implements ApplicationContextAware {

	private static ApplicationContext applicationContext;

	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.applicationContext = applicationContext;
	}

	/**
	  * get object
	  * @param name
	  * @return Object : the instance which named name
	  * @throws BeansException
	  */
	  public Object getBean(String name) throws BeansException {
	    return applicationContext.getBean(name);
	  }
}

 

分享到:
评论

相关推荐

    Spring2.5+Struts2.0+hibernate3.0+Dwr+jquery+displayTag

    2 利用struts2 的LoginAction-validation.xml 3 在bean里把service包;暴露DWR,写了一个验证用户名的流程 4 采用jpa作为POJO,还是减少配置 5 加入display的分页,并且是物理分页 打开后自已建表sql.txt jdbc....

    spring+struts+hibernate+dwr+jstl做的实例

    以用户管理为例,结合spring struts hibernate dwr jstl做的实例,struts hibernate dwr 与Spring完全结合,实现用户列表、信息增、删、改、查、维护时用户重名提示等功能,还包括页面自动转码设置(web.xml),...

    struts2+spring+jpa整合的完整例子(含分页)

    在学习jpa时候做的一个struts2+spring+jpa整合的完整例子 包含分页,一个简单的 资产入库系统 并实现了登陆等。

    dwr配置文件和注解两种方式的两个demo,ssh项目使用dwr

    dwr配置文件和注解两种方式的两个...一个sprig3+dwr3+jpa+struts2,基于注解的完整demo 一个sprig2+dwr2+hibernate3+struts1,基于配置文件的完整demo http://blog.csdn.net/zuxianghuang/article/details/7376247

    maven-framework-project:基于maven的多框架和多视图融合技术(Struts1,Struts2,Spring,SpringMVC,Hibernate,Ibatis,MyBatis,Spring Data JPA,DWR)

    请移步该项目基于maven3.0构建的,项目中融合了Struts1 , Struts2 , Spring , SpringMVC , Hibernate , Ibatis , MyBatis , Spring Data JPA , Spring JDBC , Spring DWR 。速度视图,freemarker视图,pdf...

    spring-hibernate-dwr实例

    dao.jar spring-hibernate3.jar spring-ibatis.jar spring-jdbc.jar spring-jdo.jar spring-jpa.jar spring-toplink.jar persistence.jar spring-aop.jar spring-agent.jar spring-...

    流程管理系统,rbac,dwr

    使用技术: Extjs3、Struts2、Spring、Hibernate Annotation(JPA)、JBPM4 + Android + iPhone 运行环境:Solaris+Weblogic Express+Oracle10G+JRE1.6(双机热备部署方案) 架构描述:本系统Web展现层采用了流行的...

    c3p0-0.9.1.2等等

    antlr-2.7.6rc1.jar(下面的...spring-jpa-2.0-m2 spring-struts spring-web spring-webmvc sqljdbc struts velocity-1.5 velocity-tools-1.3 xapool xerces-2.6.2 xml-apis (我做毕业设计时,用到的。需要的话拿去用)

    Spring in Action(第二版 中文高清版).part2

    6.4.3 在Spring 2.0里声明事务 6.4.4 定义注释驱动事务 6.5 小结 第7章 保护Spring 7.1 Spring Security介绍 7.2 验证用户身份 7.2.1 配置Provider Manager 7.2.2 根据数据库验证身份 7.2.3 根据LDAP仓库...

    Spring in Action(第二版 中文高清版).part1

    6.4.3 在Spring 2.0里声明事务 6.4.4 定义注释驱动事务 6.5 小结 第7章 保护Spring 7.1 Spring Security介绍 7.2 验证用户身份 7.2.1 配置Provider Manager 7.2.2 根据数据库验证身份 7.2.3 根据LDAP仓库...

    ssh+ssj+ssi jar包第一部分

    苦恼直接使用此包可以进行ssh ssi ssj 使用jpa开发时支持给中ROM,版本:struts2.1.8+spring2.5.6+ibatis2.3+hibernate3.3.2+structjson+dwr不多说了 分两部分,因为每次不超过 15M, 这些包一共 18M多 第二部分 ...

    Spring in Action(第2版)中文版

    16.5spring中带有dwr的支持ajax的应用程序 16.5.1直接web远程控制 16.5.2访问spring管理的beandwr 16.6小结 附录a装配spring a.1下载spring a.1.1研究spring发布 a.1.2构建自己的类路径 a.2把spring添加为一...

    Spring Recipes: A Problem-Solution Approach, Second Edition

    * Delivering web applications with Spring Web Flow, Spring MVC, Spring Portals, Struts, JSF, DWR, the Grails framework, and more. * Developing web services using Spring WS and REST; contract-last ...

    ssj+ssi+ssh 第二部分jar包

    苦恼直接使用此包可以进行ssh ssi ssj 使用jpa开发时支持给中ROM,版本:struts2.1.8+spring2.5.6+ibatis2.3+hibernate3.3.2+structjson+dwr不多说了 分两部分,因为每次不超过 15M, 这些包一共 18M多 第一部分 ...

    AJAX 入门视频之 Ext 2.0.1 & DWR 1表格实时编辑器实例

    带用DWR 1 (不用DWR 2 是因为2个头太大了)开发的后台服务器端,没有整合Spring,JPA啊,Struts,Hibernate等等的流感框架, 这样总的代码非常的小,省得当大家接触到了一些大量的自己不熟悉的框架的时候会产生发晕的感觉,...

    培训体系管理系统-oracle-ssh

    spring-jdo.jar spring-jpa.jar spring-portlet.jar spring-struts.jar spring-tomcat-weaver.jar spring-toplink.jar spring-web.jar spring-webmvc.jar standard.jar struts.jar swarmcache-1.0rc2.jar velocity-...

    基于项目驱动的实践教学支撑系统 (2015年)

    在具体实现上,按分层结构组织程序,用XML文件描述功能元数据,以MySQL作为后台数据库,采用最新Java EE技术架构SSHJ( Struts 2+Spring+JPA+Hibernate),通过Activiti 5工作流技术实现任务建模与管理,并利用DWR技术改进...

    Spring攻略(第二版 中文高清版).part1

    6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...

    Spring攻略(第二版 中文高清版).part2

    6.3 将Spring与Struts 1.x集成 220 6.3.1 问题 220 6.3.2 解决方案 220 6.3.3 工作原理 220 6.4 将Spring与JSF集成 226 6.4.1 问题 226 6.4.2 解决方案 226 6.4.3 工作原理 227 6.5 将Spring与DWR...

    j2ee-framework

    该项目基于maven3.0构建的,项目中融合了Struts1、Struts2、Spring、SpringMVC、Hibernate、Ibatis、MyBatis、Spring Data JPA、Spring JDBC、Spring DWR。页面展现这里使用Struts1、Struts2、SpringMVC(jsp视图、...

Global site tag (gtag.js) - Google Analytics