- 浏览: 253768 次
- 性别:
- 来自: 北京
-
最新评论
-
Nabulio:
good
Spring配置SessionFactory -
唤流年:
[color=red][/color] ...
Spring配置SessionFactory -
wangcl011:
Oracle通过数据泵网络导入另一个数据库,不生成DMP文件, ...
oracle命令导入dmp文件 -
rochou:
第一个Hibernate实现CRUD -
ningwuyu:
Entity 类是那个jar里面的
PropertyUtils MethodUtils用法
文章列表
<constant name="struts.devMode" value="true" />
<package name="front" extends="struts-default" namespace="/">
<action name="index" class="com.bjsxt.struts2.front.action.IndexAction1">
...
<?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>
<constant name="struts.devMode& ...
1.查看源码:(struts2-core-2.1.6.jar-properties-Java Source Attachment)
...\struts-2.1.8.1\src\core\src\main\java
2.自动提示:(xml-catalog)
...\struts-2.1.8.1\src\core\src\main\resources\struts-2.0.dtd
3.配置javadoc(struts2-core-2.1.6.jar-properties-JavaDoc location)
...\struts-2.1.8.1\docs\st ...
在struts.xml中配置常量:
<constant name="struts.devMode" value="true" />
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apac ...
继承HibernateDaoSupport有三种方式:
1.
@Component("logDAO")
public class LogDAOImpl extends HibernateDaoSupport implements LogDAO {
public void save(Log log) {
this.getHibernateTemplate().save(log);
}
}
xml中注入:
<bean id="hibernateTemplate" class="org.springframew ...
package com.zchen.dao.impl;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;
import com.zchen.dao.UserDAO;
import com.zchen.model.User;
@Component("userDao")
...
1.不用dataSource引入hibernate.cfg.xml
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value> ...
<aop:aspectj-autoproxy proxy-target-class="true"/>
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
& ...
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http: ...
1.直接引入:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value=" ...
package com.zchen.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
public class LogInterceptor {
public void myMetho ...
package com.zchen.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
...
引入:aop scheme。
<?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:context="http://www.springframework.org/schema/context&q ...
package com.zchen.service;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cont ...
Annotation中的@Scope注解和xml中的Scope是一样的:
这里不多作解释:属性值可以参考xml的Scope作用范围。
@Component("userService")
@Scope(value="singeleton")
public class UserService {