1.Project:

  ER图:

  applicationContext.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: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-4.3.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">
<!-- dataSource数据源 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/test">
</property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean> <!-- sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>cn/zzsxt/myblog/model/TblPhoto.hbm.xml</value>
<value>cn/zzsxt/myblog/model/TblUser.hbm.xml</value>
<value>cn/zzsxt/myblog/model/TblArticle.hbm.xml</value>
<value>
cn/zzsxt/myblog/model/TblArticletype.hbm.xml
</value>
</list>
</property>
</bean> <!-- hibernateTemplate ,并注入sessionFactory-->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- DAO -->
<bean id="tblUserDao" class="cn.zzsxt.myblog.dao.impl.TblUserDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblArticleTypeDao" class="cn.zzsxt.myblog.dao.impl.TblArticleTypeDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblArticleDao" class="cn.zzsxt.myblog.dao.impl.TblArticleDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="tblPhotoDao" class="cn.zzsxt.myblog.dao.impl.TblPhotoDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean> <!-- Service -->
<bean id="tblUserService" class="cn.zzsxt.myblog.service.impl.TblUserServiceImpl">
<property name="tblUserDao" ref="tblUserDao"></property>
</bean>
<bean id="tblArticleTypeService" class="cn.zzsxt.myblog.service.impl.TblArticleTypeServiceImpl">
<property name="tblArticletypeDao" ref="tblArticleTypeDao"></property>
</bean>
<bean id="tblArticleService" class="cn.zzsxt.myblog.service.impl.TblArticleServiceImpl">
<property name="articleDao" ref="tblArticleDao"></property>
</bean>
<bean id="tblPhotoService" class="cn.zzsxt.myblog.service.impl.TblPhotoServiceImpl">
<property name="tblPhotoDao" ref="tblPhotoDao"></property>
</bean> <!-- Action -->
<bean id="tblUserAction" class="cn.zzsxt.myblog.action.TblUserAction" scope="prototype">
<property name="tblUserService" ref="tblUserService"></property>
</bean>
<bean id="tblArticleTypeAction" class="cn.zzsxt.myblog.action.ArticleTypeAction" scope="prototype">
<property name="articleTypeService" ref="tblArticleTypeService"></property>
</bean>
<bean id="tblArticleAction" class="cn.zzsxt.myblog.action.ArticleAction" scope="prototype">
<property name="articleTypeService" ref="tblArticleTypeService"></property>
<property name="articleService" ref="tblArticleService"></property>
</bean>
<bean id="tblPhotoAction" class="cn.zzsxt.myblog.action.TblPhotoAction" scope="prototype">
<property name="photoService" ref="tblPhotoService"></property>
</bean> <!-- spring声明式事务 -->
<!-- 事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* cn.zzsxt.myblog.service.*.*(..))" id="serviceMethod"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/>
</aop:config>
</beans>

  struts.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.multipart.maxSize" value="20971520"></constant>
<package name="myblog" extends="struts-default">
<!-- struts2.3以前的版本不需要添加,struts2.5以后的版本添加通配符调用的访问限制 -->
<global-allowed-methods>regex:.*</global-allowed-methods> <action name="user-*" class="tblUserAction" method="{1}">
<result name="success">/index.jsp</result>
<result name="login">/login.jsp</result>
</action>
<action name="type-*" class="tblArticleTypeAction" method="{1}">
<result name="success" type="redirectAction">type-list</result>
<result name="list">/type_list.jsp</result>
</action> <action name="article-*" class="tblArticleAction" method="{1}">
<result name="add">/article_add.jsp</result>
<result name="success" type="redirectAction">article-list</result>
<result name="list">/article_list.jsp</result>
</action> <action name="photo-*" class="tblPhotoAction" method="{1}">
<result name="success" type="redirectAction">photo-list</result>
<result name="list">/photo_list.jsp</result>
</action>
</package>
</struts>

  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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>myBlog</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 解决Post请求乱码的过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 解决session拦截加载问题:OSIV(OpenSessionInViewFilter) -->
<filter>
<filter-name>isovFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>isovFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
struts2核心过滤器
struts2.3.3的核心过滤器:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts2.5核心过滤器:org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

  

java:Spring框架4(Project,ER图)的更多相关文章

  1. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:SSH框架(Struts2+Spring+Hibernate)搭建整合详细步骤

    在实际项目的开发中,为了充分利用各个框架的优点,通常都会把 Spring 与其他框架整合在一起使用. 整合就是将不同的框架放在一个项目中,共同使用它们的技术,发挥它们的优点,并形成互补.一般而言,在进 ...

  2. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:SSM(Spring+Spring MVC+MyBatis)框架整合搭建详细步骤

    因为 Spring MVC 是 Spring 框架中的一个子模块,所以 Spring 与 SpringMVC 之间不存在整合的问题.实际上,SSM 框架的整合只涉及 Spring 与 MyBatis ...

  3. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring DI(依赖注入)的实现方式属性注入和构造注入

    依赖注入(Dependency Injection,DI)和控制反转含义相同,它们是从两个角度描述的同一个概念. 当某个 Java 实例需要另一个 Java 实例时,传统的方法是由调用者创建被调用者的 ...

  4. [Java]Spring框架

    在这里学习Spring框架: >>spring&struts框架学习 >>spring >>Java回顾之Spring基础 >>IBM Java ...

  5. 基于java spring框架开发部标1078视频监控平台精华文章索引

    部标1078视频监控平台,是一个庞杂的工程,涵盖了多层协议,部标jt808,jt809,jt1078,苏标Adas协议等,多个平台功能标准,部标796标准,部标1077标准和苏标主动安全标准,视频方面 ...

  6. 《Java Spring框架》SpringXML配置详解

    Spring框架作为Bean的管理容器,其最经典最基础的Bean配置方式就是纯XML配置,这样做使得结构清晰明了,适合大型项目使用.Spring的XML配置虽然很繁琐,而且存在简洁的注解方式,但读懂X ...

  7. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring使用AspectJ开发AOP基于XML和基于Annotation

    AspectJ 是一个基于 Java 语言的 AOP 框架,它扩展了 Java 语言.Spring 2.0 以后,新增了对 AspectJ 方式的支持,新版本的 Spring 框架,建议使用 Aspe ...

  8. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring JDK动态代理

    JDK 动态代理是通过 JDK 中的 java.lang.reflect.Proxy 类实现的.下面通过具体的案例演示 JDK 动态代理的使用. 1. 创建项目 在 MyEclipse 中创建一个名称 ...

  9. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:第一个Spring程序

    1. 创建项目 在 MyEclipse 中创建 Web 项目 springDemo01,将 Spring 框架所需的 JAR 包复制到项目的 lib 目录中,并将添加到类路径下,添加后的项目如图 2. ...

  10. 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring IoC容器BeanFactory和ApplicationContext

    IoC 是指在程序开发中,实例的创建不再由调用者管理,而是由 Spring 容器创建.Spring 容器会负责控制程序之间的关系,而不是由程序代码直接控制,因此,控制权由程序代码转移到了 Spring ...

随机推荐

  1. gson转换问题

    list集合中integer问题 List<Integer> lists= gson.fromJson(params.get("lists"), new TypeTok ...

  2. jar is not a valid DFS filename

  3. C风格函数

    很多C风格的函数用起来非常舒适,例如: if(access(sPath, 0) == 0){ ://检测文件是否存在 } 用来测试文件存在与否,以及读写权限. 而他有宽字节版与ascii码版 宽版 _ ...

  4. HDU6579 Operation

    题目链接 问题分析 区间求异或和最大,比较自然的想到了线性基.而每次求一个区间的线性基显然是行不通的.我们考虑在每个位置求出首位置到当前位置的线性基.同时我们要使线性基中高位的位置所选的数尽量靠后.这 ...

  5. R_Studio(学生成绩)对数据缺失值md.pattern()、异常值分析(箱线图)

    我们发现这张Gary.csv表格存在学生成绩不完全的(五十三名学生,三名学生存在成绩不完整.共四个不完整成绩) 79号大学语文.高等数学 96号中国近代史纲要 65号大学体育 (1)NA表示数据集中的 ...

  6. vue-router中,require代替import解决vue项目首页加载时间过久的问题

    vue的路由配置文件(routers.js),一般使用import引入的写法,当项目打包时路由里的所有component都会打包在一个js中,在项目刚进入首页的时候,就会加载所有的组件,所以导致首页加 ...

  7. Java使用FileOutputStream写入文件

    From: http://beginnersbook.com/2014/01/how-to-write-to-a-file-in-java-using-fileoutputstream/ /* 使用F ...

  8. java web项目启动时浏览器路径不用输入项目名称方法

    http://blog.csdn.net/qq542045215/article/details/44923851

  9. Springboot 项目中引入WebSocket后,单元测试出现错误

    报错信息 java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test. ...

  10. .py与.pyc文件区别

    原来Python的程序中,是把原始程序代码放在.py文件里,而Python会在执行.py文件的时候.将.py形式的程序编译成中间式文件(byte-compiled)的.pyc文件,这么做的目的就是为了 ...