java:Spring框架4(Project,ER图)
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图)的更多相关文章
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:SSH框架(Struts2+Spring+Hibernate)搭建整合详细步骤
在实际项目的开发中,为了充分利用各个框架的优点,通常都会把 Spring 与其他框架整合在一起使用. 整合就是将不同的框架放在一个项目中,共同使用它们的技术,发挥它们的优点,并形成互补.一般而言,在进 ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:SSM(Spring+Spring MVC+MyBatis)框架整合搭建详细步骤
因为 Spring MVC 是 Spring 框架中的一个子模块,所以 Spring 与 SpringMVC 之间不存在整合的问题.实际上,SSM 框架的整合只涉及 Spring 与 MyBatis ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring DI(依赖注入)的实现方式属性注入和构造注入
依赖注入(Dependency Injection,DI)和控制反转含义相同,它们是从两个角度描述的同一个概念. 当某个 Java 实例需要另一个 Java 实例时,传统的方法是由调用者创建被调用者的 ...
- [Java]Spring框架
在这里学习Spring框架: >>spring&struts框架学习 >>spring >>Java回顾之Spring基础 >>IBM Java ...
- 基于java spring框架开发部标1078视频监控平台精华文章索引
部标1078视频监控平台,是一个庞杂的工程,涵盖了多层协议,部标jt808,jt809,jt1078,苏标Adas协议等,多个平台功能标准,部标796标准,部标1077标准和苏标主动安全标准,视频方面 ...
- 《Java Spring框架》SpringXML配置详解
Spring框架作为Bean的管理容器,其最经典最基础的Bean配置方式就是纯XML配置,这样做使得结构清晰明了,适合大型项目使用.Spring的XML配置虽然很繁琐,而且存在简洁的注解方式,但读懂X ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring使用AspectJ开发AOP基于XML和基于Annotation
AspectJ 是一个基于 Java 语言的 AOP 框架,它扩展了 Java 语言.Spring 2.0 以后,新增了对 AspectJ 方式的支持,新版本的 Spring 框架,建议使用 Aspe ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring JDK动态代理
JDK 动态代理是通过 JDK 中的 java.lang.reflect.Proxy 类实现的.下面通过具体的案例演示 JDK 动态代理的使用. 1. 创建项目 在 MyEclipse 中创建一个名称 ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:第一个Spring程序
1. 创建项目 在 MyEclipse 中创建 Web 项目 springDemo01,将 Spring 框架所需的 JAR 包复制到项目的 lib 目录中,并将添加到类路径下,添加后的项目如图 2. ...
- 吴裕雄--天生自然JAVA SPRING框架开发学习笔记:Spring IoC容器BeanFactory和ApplicationContext
IoC 是指在程序开发中,实例的创建不再由调用者管理,而是由 Spring 容器创建.Spring 容器会负责控制程序之间的关系,而不是由程序代码直接控制,因此,控制权由程序代码转移到了 Spring ...
随机推荐
- 标准C语言(4)
分支语句可以在程序执行的时候从几组语句里选择一组,执行而忽略其他组,在编写程序的时候如果遇到多种可能性,每种可能性需要专门的语句处理,这种情况下就可以考虑采用分支结构解决问题 if关键字可以用来编写分 ...
- Addthis分享插件后url乱码的解决办法
Addthis分享插件安装后,有时候URL后面会出现类似#.VB4mxhbjtnQ的一串乱码的乱码,作用是用来追踪客户客户,但是给客户的印象会以为木马中毒之类的 http://localhost/mi ...
- RMQ最大值最小值
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using ...
- GO (待更新)
日期20190531,GO AND TOOLS FOR HOME 0 环境搭建 https://golang.org/dl/ Install the Go tools If you are upgr ...
- super运行错误解决方法
自己实践: 要是下面的不成功,可能的原因是: 目录/var/log/supervisor//var/log/supervisor/ /var/log/supervisor/ /var/log/supe ...
- button 文字图片上下/左右经常会用到,记录一下
上下: self.button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平 ...
- poj1830 开关问题[高斯消元]
其实第一反应是双向BFS或者meet in middle,$2^{14}$的搜索量,多测,应该是可以过的,但是无奈双向BFS我只写过一题,已经不会写了. 发现灯的操作情况顺序不影响结果,因为操作相当于 ...
- visudo修改编辑器vim
update-alternatives --config editor
- 一例基于thinkphp,jquery和bootstrap渲染的查询数据分页器
对于某些查询记录很多的结果,web页面不得不采用分页器,现在奉上一例代码,其主要逻辑是:由页面的dom 节点发起ajax请求,返回的查询结果根据页面布局需要进行切片:并根据总记录数和页面展现的条数算出 ...
- LINUX装机问题:无法使用“Ctrl+Alt+[F1~F6]”快捷键切换到终端
用VMware装LINUX虚拟机之后,你会发现在X Window的登陆界面无法使用“Ctrl+Alt+[F1~F6]”快捷键切换到终端,这是因为VMware默认的快捷键也是Ctrl+Alt,所以你只需 ...