ssh框架搭建完成后配置
来源:互联网 发布:知乎钓鱼岛问题 编辑:程序博客网 时间:2024/06/13 05:14
beans.xml
<?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://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <!--扫描com.ldu下的注解--> <context:annotation-config></context:annotation-config> <context:component-scan base-package="com.ldu"></context:component-scan><!--配置aop--><bean id="userLog" class="com.ldu.third.aop.UserLog"></bean> <aop:config> <aop:aspect id="saveAs" ref="userLog"> <aop:pointcut expression="execution(public * com.ldu.third.service.*.*(..))" id="test"/> <aop:after method="afterSave" pointcut-ref="test"/> <aop:before method="beforeSave" pointcut-ref="test"/> </aop:aspect> </aop:config> <!--配置数据库相关mysql--> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://127.0.0.1:3306/myssh" /> <property name="username" value="root" /> <property name="password" value="123456" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>com.ldu.easyui.model</value> </list> </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="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 通过xml配置事务管理--> <!-- <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <aop:config> <aop:pointcut expression="execution(* com.ldu.third.service.*.*(..))" id="businessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="businessService" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> --><!--通过注解配置--><!-- <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:annotation-driven transaction-manager="txManager"/> --></beans>
action的注解可以加上
@Component@Scope("prototype")//当有请求的时候 都创建一个Action对象public class LoginAction extends ActionSupport{
使用注解配置事务管理时java中注解的写法
public interface LoginManager { public void add(User user); public List<User> lookUsers(); public boolean delete(int id); public void updateUser(User user); public User find(int id); @Transactional(propagation=Propagation.REQUIRED) public void deladdTest();}
web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!--启动时监听器启动spring容器--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> <!-- default: /WEB-INF/applicationContext.xml --> </listener> <!--修改默认beans.xml路径--> <context-param> <param-name>contextConfigLocation</param-name> <!-- <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value> --> <param-value>classpath:beans.xml</param-value> </context-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>
项目大体结构
阅读全文
0 0
- ssh框架搭建完成后配置
- SSH框架搭建配置
- SSH框架搭建+log4j配置
- ssh 搭建框架spring相关配置(1)
- ssh 搭建框架spring相关配置(2)
- 搭建SSH框架之配置Struts2
- [SSH框架初学笔记]ssh环境搭建及配置
- SSH框架集成后XML配置事物管理
- S2S3H4 SSH框架 搭建 环境配置及测试
- 在J2EE Eclipse上配置Mysql----SSH框架搭建1
- 基于Eclipse搭建SSH框架:第一篇 配置struts2
- myeclipse10.7上搭建ssh框架,并完成登录验证功能。
- SSH框架完全搭建好但是spring就是不能完成注入
- SSH框架搭建
- ssh框架搭建问题解决
- ssh框架搭建
- 快速搭建ssh框架
- SSH框架搭建流程
- Python3、setuptools、Pip3安装详解
- python 合并同一路径下的同类型文件
- tf.nn.l2_loss
- CHILDBIRTH TRADITIONS AROUND THE WORLD: CHINA
- 获取android sd卡中某个文件夹下的所有图片
- ssh框架搭建完成后配置
- loadrunner 压力测试 平均响应时间20秒 100用户并发 jquery.easyui.min.js 和jquery.js占用时间最长
- 顺序栈
- go语言入门
- 把数组排成最小的数
- 流行编程语言的详细对比(8)--容器类
- SAP-MM-PA精解分析系列之供应商(02)-账户组解析
- 【POJ 1724】Roads (限制最短路)
- jq 创建节点