SHH基础框架配置
2016-02-23 18:41
405 查看
jdbc.properties
log4j.properties
ApplicationContext.xml----Spring
struts.xml
web.xml
jdbc.driver = com.mysql.jdbc.Driver jdbc.url = jdbc:mysql:///shop jdbc.user = root jdbc.password =123456
log4j.properties
### direct log messages to stdout ### log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n ### direct messages to file mylog.log ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=c:/mylog.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n ### set log levels - for more verbose logging change 'info' to 'debug' ### log4j.rootLogger=info, stdout
ApplicationContext.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:property-placeholder location="classpath:jdbc.properties"/> <!-- 配置C3P0 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driver}"/> <property name="jdbcUrl" value="${jdbc.url}"/> <property name="user" value="${jdbc.user}"/> <property name="password" value="${jdbc.password}"/> </bean> <!-- hibernate的相关信息 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 注入连接池 --> <property name="dataSource" ref="dataSource"/> <!-- 配置hibernate的其他属性 --> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> <prop key="hibernate.connection.autocommit">false</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <!-- 配置hibernate的映射文件 --> <property name="mappingResources"> <list> <value>cn/itcast/shop/user/vo/User.hbml.xml</value> </list> </property> </bean> <!-- 事务管理 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 开启注解事务 --> <tx:annotation-driven transaction-manager="transactionManager"/> <!-- Action的配置=================================================== --> <!--scope="prototype" 可以保证 当有请求的时候 都创建一个Action对象,保证安全 --> <!-- 首页访问的Action--> <bean id="indexAction" class="cn.itcast.shop.index.action.IndexAction" scope="prototype"> <property name="categoryService" ref="categoryService"/> <property name="productService" ref="productService"></property> </bean> <!-- Service的配置====================================================== --> <bean id="userService" class="cn.itcast.shop.user.service.UserService"> <property name="userDao" ref="userDao"/> </bean> <!-- Dao的配置========================================================== --> <bean id="userDao" class="cn.itcast.shop.user.dao.UserDao"> <property name="sessionFactory" ref="sessionFactory"/><!-- 注入上面spring配置的hibernate信息的sessionFactory --> </bean>
</beans>
struts.xml
<?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>
</struts>
web.xml
<!-- 配置Spring的核心监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 全局参数,默认加载web-inf目录下的配置文件(applicationContext.xml),在此处进行修改 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- 配置struts2的核心过滤器 --> <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> <!-- 拦截请求和转发 --> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>
相关文章推荐
- shell for in 用法总结
- Python socket超时
- 第一周总结
- 【马哥原创】haproxy官方中文入门文档教程
- CCNode节点类和获取当前语言
- ARM 汇编学习——编写简单的ARM汇编程序
- 2016-02-23 AFNetworing 的使用中出现的问题
- 自私的基因读后感
- html的各种 2
- 模板
- 类模板遇上友元函数
- 查看java进程的所有信息
- LeetCode Algorithms #326 <Power of Three>
- nginx的两种配置用户权限访问
- At24lc512存储器访问内部地址方法---i2c通信获取
- RedhatEnterpriseLinux7安装系统过程的日志
- 面试题
- HTML基础(jQuery)
- markdown简单常用语法
- IE浏览器对域名的限制