81,092
社区成员
发帖
与我相关
我的任务
分享
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" 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/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config></context:annotation-config>
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
<property name="url" value="jdbc:db2://ip/dbname"/>
<property name="username" value="username" />
<property name="password" value="pwd" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="jfAccountMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.xxx.interfaces.JfAccountMapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
</beans
public class *Action extends ActionSupport{
private JfAccountMapper jfAccountMapper ;
public void setJfAccountMapper(JfAccountMapper jfAccountMapper ){
this.jfAccountMapper = jfAccountMapper ;
}
public JfAccountMapper getJfAccountMapper (){
return jfAccountMapper ;
}
@Tansactional
public String save(){
JfAccount obj = new JfAccount();
obj.setProperty(); //
jfAccountMapper .insert();
flag = true; // 这里设置一个标志用于ajax提交返回结果
return SUCCESS
}
}