- 浏览: 733935 次
- 性别:
- 来自: 重庆
文章分类
- 全部博客 (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 条形码生成(一维条形码)
web.xml 文件/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rolemanager.service;
import java.io.Serializable;
import java.util.Collection;
import org.springframework.dao.DataAccessException;
/**
*
* @author liuqing
*/
public interface IBaseService<T extends Serializable> {
public T queryById(int id) throws DataAccessException;
public Collection<T> queryAll() throws DataAccessException;
public void add(T t) throws DataAccessException;
public void remove(T t) throws DataAccessException;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rolemanager.service.impl;
import com.rolemanager.dao.IBaseDao;
import com.rolemanager.service.IBaseService;
import java.io.Serializable;
import java.util.Collection;
import org.springframework.dao.DataAccessException;
/**
*
* @author liuqing
*/
public class BaseServiceImpl<T extends Serializable> implements IBaseService<T> {
private IBaseDao<T> baseDao;
public T queryById(int id) throws DataAccessException {
return this.baseDao.queryById(id);
}
public Collection<T> queryAll() throws DataAccessException {
return this.baseDao.queryAll();
}
public void add(T t) throws DataAccessException {
this.baseDao.add(t);
}
public void remove(T t) throws DataAccessException {
this.baseDao.remove(t);
}
public IBaseDao<T> getBaseDao() {
return baseDao;
}
public void setBaseDao(IBaseDao<T> baseDao) {
this.baseDao = baseDao;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rolemanager.service;
import com.rolemanager.GroupInfo;
/**
*
* @author liuqing
*/
public interface IGroupInfoService extends IBaseService<GroupInfo> {
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rolemanager.service.impl;
import com.rolemanager.GroupInfo;
import com.rolemanager.service.IGroupInfoService;
/**
*
* @author liuqing
*/
public class GroupInfoServiceImpl extends BaseServiceImpl<GroupInfo> implements IGroupInfoService{
public String queryName() {
return this.getBaseDao().queryById(2).getUserInfoes().iterator().next().getPassword();
}
}
<?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"> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/com/rolemanager/conf/applicationContext-*.xml </param-value> </context-param> <filter> <filter-name>login</filter-name> <filter-class>com.baseaction.LoginFilter</filter-class> </filter> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!--Struts Filter--> <filter> <filter-name>struts2</filter-name> <filter-class>com.rolemanager.Ng2Filter</filter-class> </filter> <filter-mapping> <filter-name>login</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
applicationContext-app 项目核心文件
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="configLocation"> <value> classpath:hibernate.cfg.xml </value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" > <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务拦截器 --> <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <!-- 事务拦截器bean需要依赖注入一个事务管理器 --> <property name="transactionManager" ref="transactionManager" /> <property name="transactionAttributes"> <!-- 下面定义事务传播属性--> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- 定义BeanNameAutoProxyCreator--> <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <!-- 指定对满足哪些bean name的bean自动生成业务代理 --> <property name="beanNames"> <!-- 下面是所有需要自动创建事务代理的bean--> <list> <value>*Service</value> </list> <!-- 此处可增加其他需要自动创建事务代理的bean--> </property> <!-- 下面定义BeanNameAutoProxyCreator所需的事务拦截器--> <property name="interceptorNames"> <list> <!-- 此处可增加其他新的Interceptor ,下面的拦截器仅用于生成 事务代理--> <value>transactionInterceptor</value> </list> </property> </bean> </beans>
applicationContext-dao Dao层
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <bean id="userInfoDao" class="com.rolemanager.dao.impl.UserInfoDaoImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="groupInfoDao" parent="userInfoDao" class="com.rolemanager.dao.impl.GroupInfoDaoImpl"> </bean> <bean id="menuInfoDao" parent="userInfoDao" class="com.rolemanager.dao.impl.MenuInfoDaoImpl"> </bean> <bean id="menuItemDao" parent="userInfoDao" class="com.rolemanager.dao.impl.MenuItemDaoImpl"> </bean> <bean id="resourceTypeDao" parent="userInfoDao" class="com.rolemanager.dao.impl.ResourceTypeDaoImpl"> </bean> <bean id="resourceInfoDao" parent="userInfoDao" class="com.rolemanager.dao.impl.ResourceInfoDaoImpl"> </bean> <bean id="roleInfoDao" parent="userInfoDao" class="com.rolemanager.dao.impl.RoleInfoDaoImpl"> </bean> </beans>
applicationContext-service
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:security="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <bean id="userInfoService" class="com.rolemanager.service.impl.UserInfoServiceImpl"> <property name="baseDao" ref="userInfoDao" /> </bean> <bean id="groupInfoService" class="com.rolemanager.service.impl.GroupInfoServiceImpl"> <property name="baseDao" ref="groupInfoDao" /> </bean> <bean id="menuInfoService" class="com.rolemanager.service.impl.MenuInfoServiceImpl"> <property name="baseDao" ref="menuInfoDao" /> </bean> <bean id="menuItemService" class="com.rolemanager.service.impl.MenuItemServiceImpl"> <property name="baseDao" ref="menuItemDao" /> </bean> <bean id="resourceTypeService" class="com.rolemanager.service.impl.ResourceTypeServiceImpl"> <property name="baseDao" ref="resourceTypeDao" /> </bean> <bean id="resourceInfoService" class="com.rolemanager.service.impl.ResourceInfoServiceImpl"> <property name="baseDao" ref="resourceInfoDao" /> </bean> <bean id="roleInfoService" class="com.rolemanager.service.impl.RoleInfoServiceImpl"> <property name="baseDao" ref="roleInfoDao" /> </bean> </beans>
反射与泛性应用
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rolemanager.dao; import java.io.Serializable; import java.util.Collection; import org.springframework.dao.DataAccessException; /** * * @author liuqing */ public interface IBaseDao<T extends Serializable> { public T queryById(int id) throws DataAccessException; public Collection<T> queryAll() throws DataAccessException; public void add(T t) throws DataAccessException; public void remove(T t) throws DataAccessException; } /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rolemanager.dao.impl; import com.rolemanager.dao.IBaseDao; import java.io.Serializable; import java.lang.reflect.ParameterizedType; import java.util.Collection; import org.hibernate.criterion.DetachedCriteria; import org.springframework.dao.DataAccessException; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** * * @author liuqing */ public class BaseDaoImpl<T extends Serializable> extends HibernateDaoSupport implements IBaseDao<T> { private Class<T> entityClass; public BaseDaoImpl() { entityClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } public T queryById(int id) throws DataAccessException { return this.getHibernateTemplate().get(entityClass, id); } public Collection<T> queryAll() throws DataAccessException { DetachedCriteria detached = DetachedCriteria.forClass(entityClass); return this.getHibernateTemplate().findByCriteria(detached); } public void add(T t) throws DataAccessException { this.getHibernateTemplate().save(t); } public void remove(T t) throws DataAccessException { this.getHibernateTemplate().delete(t); } } /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rolemanager.dao; import com.rolemanager.GroupInfo; /** * * @author liuqing */ public interface IGroupInfoDao extends IBaseDao<GroupInfo> { } /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.rolemanager.dao.impl; import com.rolemanager.GroupInfo; import com.rolemanager.dao.IGroupInfoDao; /** * * @author liuqing */ public class GroupInfoDaoImpl extends BaseDaoImpl<GroupInfo> implements IGroupInfoDao { }
同理Service
发表评论
-
Spring mvc Token
2015-08-03 19:40 984request.getSession(false).s ... -
Spring dao 和Service 生成文件类
2012-02-13 09:23 2216package com.annotationtodaotose ... -
Spring 与struts2 和Hibernate 4.0 + Dwr 注解解决方安
2011-12-11 17:39 36471. web.xml 注册文件 < ... -
Spring jdbc 操作存储过程
2011-07-26 14:14 3859首先我们要用Spring 与 Jdbc 调用存储过程 ... -
Spring 调用jndi 数据源 struts + hibernate + spring 整合
2011-06-15 17:29 1678<?xml version="1.0" ... -
SpringSecurity 2中文文档
2011-05-26 10:46 1074有不少同事在问spring security 2 有没有中文的 ... -
Spring3.0 Struts2 Hibernate 开发精华
2010-11-29 17:20 15611. 自动添加事务管理应用声明性事务 2. 直接引用hibe ... -
acegi web.xml
2010-10-24 23:14 1134<?xml version="1.0&q ... -
在web.xml 文件下添加 OpenEntityManagerInViewFilter
2010-06-17 13:35 3586错误原因 13:34:34,859 ERROR LazyIni ...
相关推荐
spring mvc hibernate整合,采用MyEclipse自动生成包和配置文件,jar包可能有多余,但是不影响整体效果。服务器tomcat。数据库mysql。
<description>Spring公共配置文件 <!-- mes 的數據庫 --> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/> ...
让Spring自动扫描和管理Bean 15.使用JDK中的Proxy技术实现AOP功能 16.使用CGLIB实现AOP功能与AOP概念解释 17.使用Spring的注解方式实现AOP入门 18.使用Spring的注解方式实现AOP的细节 19.使用Spring配置文件...
(2) spring-beans.jar 这个jar文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean以及进行Inversion of Control / Dependency Injection(IoC/DI)操作相关的所有类。如果应用只需基本的IoC/DI支持,...
二、 建立spring的配置文件 8 三、 引入spring的jar包 8 四、 测试代码: 8 五、 注意接口的使用: 8 第五课:IOC(DI)配置及应用 9 一、 什么是IOC、DI 9 二、 编辑xml文件时,没有提示 9 三、 注入类型(Injecting ...
SPI 机制(Java SPI 实际上是“基于接口的编程+策略模式+配置文件”组合实现的动态加载机制), 很多地方有用到: AOP Spring的AOP的底层实现原理; 为什么jdk动态代理是必须是接口 两种动态代理的区别 AOP实现方式:...
2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. JPA 2.4.3. 异步的JMS 2.4.4. JDBC 2.5. Web层 2.5.1. Spring MVC的表单标签库 2.5.2. Spring MVC合理的默认值 2.5.3. Portlet 框架 2.6. 其他特性 2.6.1. ...
12. Spring 配置文件 13. 什么是 Spring IOC 容器? 14. IOC 的优点是什么? 15. ApplicationContext 通常的实现是什么? 16. Bean 工厂和 Application contexts 有什么区别? 17. 一个 Spring 的应用看起来象什么...
spring-beans.jar(必须):这 个jar 文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean 以及进行Inversion of Control / Dependency Injection(IoC/DI)操作相关的所有类。如果应用只需基本的IoC/DI ...
5.1.2 理解Spring对事务管理的支持 5.1.3 介绍Spring的事务管理器 5.2 在Spring中编写事务 5.3 声明式事务 5.3.1 理解事务属性 5.3.2 声明一个简单的事务策略 5.4 通过方法名声明事务 ...
代码及ppt涵盖 Spring4.0 的所有核心内容:在 Eclipse 中安装 SpringIDE 插件、IOC & DI、在 Spring 中配置 Bean、自动装配、Bean 之间的关系(依赖、继承)、Bean 的作用域、使用外部属性文件、SpEL、管理 Bean 的...
2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. JPA 2.4.3. 异步的JMS 2.4.4. JDBC 2.5. Web层 2.5.1. Spring MVC的表单标签库 2.5.2. Spring MVC合理的默认值 2.5.3. Portlet 框架 2.6. 其他特性 2.6.1. 动态语言...
2.2.3 类包及Spring配置文件规划 2.3 持久层 2.3.1 建立领域对象 2.3.2 UserDao 2.3.3 LoginLogDao 2.3.4 在Spring中装配DAO 2.4 业务层 2.4.1 UserService 2.4.2 在Spring中装配Service 2.4.3 单元测试 2.5 展现层 ...
这个jar文件是所有应用都要用到的,它包含访问配置文件、创建和管理bean以及进行Inversion of Control / Dependency Injection(IoC/DI)操作相关的所有类。如果应用只需基本的IoC/DI支持,引入spring-core.jar及...
5、测试Spring+mybatis的框架搭建,写单元测试JUnit,测试事务配置等:model-->dao(mapper)-->service-->test 6、映入SpringMVC:配置SpringMVC配置信息。-->配置文件:spring-mvc.xml(扫描controller) 7...
2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. 对Websphere 事务管理的完整支持 2.4.3. JPA 2.4.4. 异步的JMS 2.4.5. JDBC 2.5. Web层 2.5.1. Spring MVC合理的默认值 2.5.2. Portlet 框架 2.5.3. 基于...
2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. 对Websphere 事务管理的完整支持 2.4.3. JPA 2.4.4. 异步的JMS 2.4.5. JDBC 2.5. Web层 2.5.1. Spring MVC合理的默认值 2.5.2. Portlet 框架 2.5.3. 基于...
2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. JPA 2.4.3. 异步的JMS 2.4.4. JDBC 2.5. Web层 2.5.1. Spring MVC的表单标签库 2.5.2. Spring MVC合理的默认值 2.5.3. Portlet 框架 2.6. 其他特性 2.6.1. ...
14.5.1.理解Spring.NET声明式事务管理的实现 14.5.2.第一个例子 14.5.3.Transaction特性的设置 14.5.4.通过AutoProxyCreator使用声明式事务 14.5.5.通过TransactionProxyFactoryObject使用声明式事务 14.5.6. 通过...