SSH整合时xml文件写法
来源:互联网 发布:淘宝网卖什么最赚钱 编辑:程序博客网 时间:2024/05/18 01:55
SSH整合时spring.xml和struts.xml两个文件中需要写的代码
这里只写几个文件中的代码 至于各个包中每个类的代码这里就不列出来了
首先是spring
<?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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><!-- 组件扫描 --><context:component-scan base-package="cn.itcast.oa"></context:component-scan><!-- 找到外部配置jdbc文件 --><context:property-placeholder location="jdbc.properties"/><!-- 配置数据源 --><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${driverClass}"></property> <property name="jdbcUrl" value="${jdbcUrl}"></property> <property name="user" value="${user}"></property> <property name="password" value="${password}"></property> <property name="initialPoolSize" value="${initialPoolSize}"></property> <property name="minPoolSize" value="${minPoolSize}"></property> <property name="maxPoolSize" value="${maxPoolSize}"></property></bean><!-- 配置sessionfactory --><bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 引用datasource --> <property name="dataSource" ref="dataSource" /> <!-- 注入hibernate属性 --> <property name="hibernateProperties"> <props> <!-- 方言 --> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <!-- 显示sql --> <prop key="hibernate.show_sql">true</prop> <!-- 格式化sql --> <prop key="hibernate.format_sql">true</prop> </props> </property> <!-- hibernate映射文件路径 --> <property name="mappingDirectoryLocations"> <list> <value>classpath:cn/itcast/oa/domain</value> </list> </property></bean><!-- 配置事务 --><bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property></bean><!-- 提供对注解的支持 --><context:annotation-config /><!-- 注解驱动 --><tx:annotation-driven transaction-manager="txManager"/></beans>
接下来是struts的
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"><struts> <!-- 开发者模式 --> <constant name="struts.devMode" value="true" /> <!-- 对象工厂指定为spring --> <constant name="struts.objectFactory" value="spring"/> <!-- 设置访问后缀 --> <package name="default" namespace="/" extends="struts-default">
web.xml
<?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"> <!-- 通过上下文参数指定spring配置文件的位置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <!-- 配置spring的上下文载入器监听器 ,项目启动时加载spring --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 配置struts2的前端控制器 --> <filter> <filter-name>struts</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
阅读全文
0 0
- SSH整合时xml文件写法
- ssh整合xml文件配置
- ssh整合application.xml文件的整合
- SSH中的各xml文件写法
- SSH架构整合-XML文件配置
- ssh整合!Struts.xml、hibernate与spring整合的applicationContext.xml、web.xml文件的配置!
- SSH 整合 web.xml
- SSH整合web.xml
- 基于Annotation注解整合SSH框架和基于XML文件配置Bean整合SSH框架
- 基于Annotation注解整合SSH框架和基于XML文件配置Bean整合SSH框架
- ssh整合文件上传
- ssh整合文件配置
- ssh整合 web.xml 配置文件
- ssh整合web.xml书写
- SSH整合之pom.xml
- SSH整合(XML版本)
- ssh整合时hibernate.cfg.xml的问题
- SSH整合时不使用hibernate.cfg.xml
- 管理者神功之“九”阴真经
- hdu4574(dfs+枚举)
- BloomFilter布隆过滤器
- Java二维数组,将古诗《相思》分别用横版和竖版的形式输出
- POJ
- SSH整合时xml文件写法
- poj 1636 DP
- android中getSystemService详解
- 快速排序
- \r和\n以及\r\n的区别 (C#\C)
- MFC 生成 exe文件的图标更改方法
- GMIS 2017大会漆远演讲:AI 驱动金融生活
- 关于parallel_case和full_case的使用
- java.io.IOException: Stream closed