1、建立项目

2、导入SSHjar包

http://pan.baidu.com/s/1hsELr04

3、引入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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>crm</display-name> <!-- 配置Spring框架整合WEB的监听器 -->
<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>
 <!-- 解决延迟加载的问题也注释掉 -->
  
<!-- 解决延迟加载的问题 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 配置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>
</filter-mapping> <!-- 程序出现了500的异常,跳转到error.jsp的页面 -->
<error-page>
<error-code>500</error-code>
<location>/jsp/error.jsp</location>
</error-page> <welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

4、导入struts.xml、log4j.properties、applicationContext.xml

<!--struts.xml基本上不需要变化,模仿写配置即可-->
<?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> <!-- 先配置包结构 -->
<package name="crm" extends="struts-default" namespace="/"> <!-- 配置全局的结果页面 -->
<global-results>
<result name="login" type="redirect">/login.jsp</result>
</global-results> <!-- 配置客户的Action,如果Action由Spring框架来管理,class标签上只需要编写ID值就OK -->
<action name="customer_*" class="customerAction" method="{1}">
<result name="page">/jsp/customer/list.jsp</result>
</action> <!-- 配置用户的模块 -->
<action name="user_*" class="userAction" method="{1}">
<result name="loginOK" type="redirect">/index.jsp</result>
</action> </package> </struts>
###log4j.properties基本上不需要变化
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.err
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
<!-- 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"> <!-- 先配置C3P0的连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql:///crm_28"/>
<property name="user" value="root"/>
<property name="password" value="root"/>
</bean> <!-- LocalSessionFactoryBean加载配置文件 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 先加载连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 加载方言,加载可选 -->
<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.hbm2ddl.auto">update</prop>
</props>
</property> <!-- 引入映射的配置文件,这部分先删除,不删除的话,会报mappingResources的问题,后面使用的时候可以模仿 -->
<property name="mappingResources">
<list>
<value>com/itheima/domain/User.hbm.xml</value>
<value>com/itheima/domain/Customer.hbm.xml</value>
<value>com/itheima/domain/Dict.hbm.xml</value>
</list>
</property>
</bean> <!-- 先配置平台事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!-- 开启事务的注解 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- 这部分一定要注释掉,因为没有类,在运行的时候,加载找不到类,后面使用的时候可以模仿 -->
    
<!-- 配置客户模块 -->
<bean id="customerAction" class="com.itheima.web.action.CustomerAction" scope="prototype">
<property name="customerService" ref="customerService"/>
</bean> <bean id="customerService" class="com.itheima.service.CustomerServiceImpl">
<property name="customerDao" ref="customerDao"/>
</bean> <bean id="customerDao" class="com.itheima.dao.CustomerDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!-- 配置用户的模块 -->
<bean id="userAction" class="com.itheima.web.action.UserAction" scope="prototype">
<property name="userService" ref="userService"/>
</bean> <bean id="userService" class="com.itheima.service.UserServiceImpl">
<property name="userDao" ref="userDao"/>
</bean> <bean id="userDao" class="com.itheima.dao.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean> </beans>

5、导入静态页面(页面有些问题)

6、运行

至此,SSH框架搭建好了,SSH框架搭建源码

http://pan.baidu.com/s/1boKKNQB

1、SSH框架整合的更多相关文章

  1. SSH框架整合

    SSH框架整合 一.原理图 action:(struts2) 1.获取表单的数据 2.表单的验证,例如非空验证,email验证等 3.调用service,并把数据传递给service Service: ...

  2. dwr与ssh框架整合教程

    (1)dwr与ssh框架整合教程dwr框架介绍. DWR(Direct Web Remoting)是一个用于改善web页面与Java类交互的远程服务器端Ajax开源框架,可以帮助开 发人员开发包含AJ ...

  3. ssh框架整合之登录以及增删改查

    1.首先阐述一下我用得开发工具,myeclipse2017+oracle,所以我的基本配置步骤可能不一样,下面我用几张图来详解我的开发步骤. ---1先配置structs (Target 选择apac ...

  4. Spring+Hibernate+Struts(SSH)框架整合

    SSH框架整合 前言:有人说,现在还是流行主流框架,SSM都出来很久了,更不要说SSH.我不以为然.现在许多公司所用的老项目还是ssh,如果改成流行框架,需要成本.比如金融IT这一块,数据库dao层还 ...

  5. J2EE进阶(十)SSH框架整合常见问题汇总(一)

    SSH框架整合常见问题汇总(一) 前言 以下所列问题具有针对性,但是遇到同类型问题时均可按照此思路进行解决. HTTP Status 404 - No result defined for actio ...

  6. MVC+Spring.NET+NHibernate .NET SSH框架整合 C# 委托异步 和 async /await 两种实现的异步 如何消除点击按钮时周围出现的白线? Linq中 AsQueryable(), AsEnumerable()和ToList()的区别和用法

    MVC+Spring.NET+NHibernate .NET SSH框架整合   在JAVA中,SSH框架可谓是无人不晓,就和.NET中的MVC框架一样普及.作为一个初学者,可以感受到.NET出了MV ...

  7. SSH框架整合的其它方式

    --------------------siwuxie095 SSH 框架整合的其它方式 1.主要是整合 Spring 框架和 Hibernate 框架时,可以不写 Hibernate 核心配置文件: ...

  8. SSH框架整合过程总结

    ---------------------siwuxie095                                 SSH 框架整合过程总结         (一)导入相关 jar 包(共 ...

  9. SSH框架整合思想

    --------------------siwuxie095                                 SSH 框架整合思想         1.SSH 框架,即 Struts2 ...

  10. SSH框架整合jar包时的注意事项

    SSH框架整合jar包时的注意事项: 在将三个框架所需的jar整合到一起后,要看一下有没有相同类型但是版本不同的jar包,如果有的话,需要把低版本的jar包删除掉,否则会报错.我这里整合的时候java ...

随机推荐

  1. mongodb 的一些启动命令

    启动命令 nohup /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod -dbpath /home/sh/local/mongod ...

  2. Oracle拆分字符串函数与执行调用

    本函数可以将“目标字符串”以“指定字符串”进行拆分,并通过表结构返回结果.代码如下: ); CREATE OR REPLACE FUNCTION splitstr(p_string IN VARCHA ...

  3. k8s1.4.3安装实践记录(3)下载基础镜像

    下载基础镜像,因为Google被墙,所以我们用时速云中的镜像来tag docker pull index.tenxcloud.com/google_containers/pause-amd64:3.0 ...

  4. HBase之八--(2):HBase二级索引之Phoenix

    1. 介绍 Phoenix 是 Salesforce.com 开源的一个 Java 中间件,可以让开发者在Apache HBase 上执行 SQL 查询.Phoenix完全使用Java编写,代码位于 ...

  5. 3D角色渲染到2D界面上

    using UnityEngine; using System.Collections; using System.Collections.Generic; using Carrie.Net; usi ...

  6. USB通信协议

    转自http://blog.csdn.net/myarrow/article/details/8484113 0. 基本概念 一个[传输](控制.批量.中断.等时):由多个[事务]组成: 一个[事务] ...

  7. C++ 栈 (链表实现)

    第一.基本概念 栈中的元素遵守“先进后出”的原则(LIFO,Last In First Out) 只能在栈顶进行插入和删除操作 压栈(或推入.进栈)即push,将数据放入栈顶并将栈顶指针加一 出栈(或 ...

  8. Idea2016远程调试Java项目

    一.在IDEA中配置远程tomcat 1.打开配置页面 选择"+" → "Tomcat Server" → "Remote" 填写名称和目标 ...

  9. IDA Pro 权威指南学习笔记(十一) - 名称与命名

    多数情况下,要修改一个名称,只需单击想要修改的名称(使其突出显示),并使用快捷键 N 打开更名对话框 右击需要修改的名称,并在出现的上下文菜单中选择 Rename 选项,也可以更改名称 参数和局部变量 ...

  10. sql server 2008 链接到数据库引擎