首先创建一个 New  =>  Web Project  起名 demo

然后在项目名称上 点击鼠标右键 选择 MyEclipse => Add Speing Capabilites...

接下来 就是选择需要加载 spring 的版本 我在这里选择 3.0

选择需要加载的库文件 Spring 3.0 Aop Libraries,core Libraries,Persistence Core Lisbraries,

还有一个  Web Libraries

后面基本上没啥了 直接 Finish 吧。

然后接着添加 hibernate

还是项目名称上 点击鼠标右键 选择 MyEclipse => Add Hibernate  Capabilites...

在这里我选择的hibernate版本是3.2

库文件分别是 Annotations & Entity Manager  和 Core Libraries

选择 Copy checked library Jars to project folder and add to build-path 将库文件复制到 /WebRoot /Web-INF/lib 目录下

接下来 选择 Next 进入下一配置页面 选择 Spring configuration file(applicationContext.xml) 让Spring 托管 hibernate的配置文件

选择 Existing Spring Configuration file

接下来配置数据库连接参数 jdbc

MySQL 配置如下:

Connect  URL:jdbc:mysql://localhost:3306/system

Driver Class:com.mysql.jdbc.Driver

Username:root

password:root

Dialect:MySQL

接下来 将 Create SessionFactory class 选项 取消,最后 Finish

最后我们来添加Struts2

还是项目名称上 点击鼠标右键 选择 MyEclipse => Add Struts Capabilites...

我们选择 struts的版本为 2.1 过滤器名称 默认为 struts2  拦截 URL pattern 选择 /* 对所有链接都进行过滤监测

接下来选择 加载库文件 在这里我选了 Core Libraries,DOJO Libraries,Spring Libraries(这是Struts 支持Spring 的库文件)

最后 选择 FINISH.

结束添加SSH框架的第一部;

接下来我们要配置  Web.xml 文件 添加 spring 的监听器 WebRoot/WEB-INf/web.xml

  1. <!-- Struts2  -->
  2. <filter>
  3. <filter-name>struts2</filter-name>
  4. <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  5. </filter>
  6. <filter-mapping>
  7. <filter-name>struts2</filter-name>
  8. <url-pattern>*.action</url-pattern>
  9. </filter-mapping>
  10. <filter-mapping>
  11. <filter-name>struts2</filter-name>
  12. <url-pattern>*.jsp</url-pattern>
  13. </filter-mapping>
  14. <listener>
  15. <listener-class>
  16. org.springframework.web.context.ContextLoaderListener
  17. </listener-class>
  18. </listener>
  19. <!-- 设置spring监听 -->
  20. <context-param>
  21. <param-name>contextConfigLocation</param-name>
  22. <param-value>classpath:applicationContext.xml</param-value>
  23. </context-param>
  24. <!-- 通用返回页面 -->
  25. <error-page>
  26. <error-code>404</error-code>
  27. <location>/page/comm/404Error.jsp</location>
  28. </error-page>
  29. <error-page>
  30. <error-code>500</error-code>
  31. <location>/page/comm/500Error.jsp</location>
  32. </error-page>

配置 applicationContext.xml 的 aop 头 文件

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop <a target="_blank" href="http://www.springframework.org/schema/aop/spring-aop-3.0.xsd'>">http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  6. </a>

配置 数据库c3p0连接池

  1. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
  2. destroy-method="close">
  3. <property name="driverClass" value="com.mysql.jdbc.Driver" />
  4. <!-- 1.需要更改数据库ip、端口、数据库名称 -->
  5. <property name="jdbcUrl"
  6. value="jdbc:mysql://127.0.0.1:3306/system_showapp?useUnicode=true&characterEncoding=utf-8" />
  7. <!-- 2.数据库用户名 -->
  8. <property name="user" value="root" />
  9. <!-- 3.数据库密码 -->
  10. <property name="password" value="rootroot" />
  11. <!--连接池中保留的最小连接数。Default: 3 -->
  12. <property name="minPoolSize" value="5" />
  13. <!--连接池中保留的最大连接数。Default: 15 -->
  14. <property name="maxPoolSize" value="20" />
  15. <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
  16. <property name="initialPoolSize" value="10" />
  17. <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
  18. <property name="maxIdleTime" value="20" />
  19. <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
  20. <property name="acquireIncrement" value="3" />
  21. <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
  22. <property name="acquireRetryAttempts" value="30" />
  23. <!--两次连接中间隔时间,单位毫秒。Default: 1000 -->
  24. <property name="acquireRetryDelay" value="1000"></property>
  25. <!--连接关闭时默认将所有未提交的操作回滚。Default: false -->
  26. <property name="autoCommitOnClose" value="false"></property>
  27. <!--
  28. JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements属于单个connection而不是整个          连接池。所以设置这个参数需要考虑到多方面的因素。
  29. 如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0
  30. -->
  31. <property name="maxStatements" value="0" />
  32. <!--每60秒检查所有连接池中的空闲连接-->
  33. <property name="idleConnectionTestPeriod" value="60" />
  34. <!--
  35. maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0
  36. -->
  37. <property name="maxStatementsPerConnection" value="0"></property>
  38. <!--
  39. 因性能消耗大请只在需要的时候使用它。如果设为true那么在每个connection提交的时候都将校验其有效性。建议使用                 idleConnectionTestPeriod或automaticTestTable
  40. 等方法来提升连接测试的性能。Default: false
  41. -->
  42. <property name="testConnectionOnCheckout" value="false"></property>
  43. <!--如果设为true那么在取得连接的同时将校验连接的有效性。Default: false -->
  44. <property name="testConnectionOnCheckin" value="true"></property>
  45. </bean>

如果有多个 applicationContext.xml文件可以在web.xml内配置

  1. <!-- 设置spring监听 -->
  2. <context-param>
  3. <param-name>contextConfigLocation</param-name>
  4. <param-value>classpath*:applicationContext*.xml</param-value>
  5. </context-param>

接着配置 struts.xml 可以多配置文件 通过 <include file="struts-1.xml"></include> 标签导入

  1. <constant name="struts.i18n.encoding" value="UTF-8" />
  2. <include file="struts-1.xml"></include>
  3. <include file="struts-2.xml"></include>
  4. <include file="struts-3.xml"></include>
  1. <package name="System" extends="struts-default" namespace="/">
  2. </package>
  3. <!--
  4. 通用拦截器 请在package 内设置继承 extends="mystruts" 每个action内添加
  5. -拦截器- 就可以进行不登陆拦截
  6. <interceptor-ref name="mystack"></interceptor-ref>
  7. -->
  8. <package name="mystruts" extends="struts-default" namespace="/">
  9. <!-- 拦截器设置 -->
  10. <interceptors>
  11. <!-- 定义的权限拦截器 -->
  12. <interceptor name="myauth" class="com.dw.util.AuthorizationInterceptor"></interceptor>
  13. <!-- 定义拦截器栈 -->
  14. <interceptor-stack name="mystack">
  15. <interceptor-ref name="defaultStack"></interceptor-ref>
  16. <interceptor-ref name="myauth"></interceptor-ref>
  17. </interceptor-stack>
  18. </interceptors>
  19. <!-- 通用返回 -->
  20. <global-results>
  21. <result name="input" type="redirect">/index.jsp</result>
  22. </global-results>
  23. </package>

添加 log4j.properties

    1. # For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml!
    2. # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J.
    3. log4j.rootLogger=INFO, stdout, logfile
    4. log4j.appender.syslog.encoding=GBK
    5. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    6. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    7. log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
    8. log4j.appender.logfile=org.apache.log4j.RollingFileAppender
    9. #log4j.appender.logfile.File=${petstore.root}/WEB-INF/petstore.log
    10. log4j.appender.logfile.File=D\:\\log4j.log
    11. log4j.appender.logfile.MaxFileSize=512KB
    12. # Keep three backup files.
    13. log4j.appender.logfile.MaxBackupIndex=3
    14. # Pattern to output: date priority [category] - message
    15. log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
    16. log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

SSH的加入顺序*(转)的更多相关文章

  1. SSH加载顺序问题

    http://bbs.csdn.net/topics/390299835 个人总结 1.项目启动首先加载WEB.xml文件 wen.xml文件中有     <!-- tomcat默认生成的地方是 ...

  2. linux ssh key配置方法

    转自:http://blog.csdn.net/zzk197/article/details/7915307 一:简洁的配置文件[root@cisco ~]# vi /etc/ssh/sshd_con ...

  3. Telnet、SSH和VNC

    以下内容出自<Red Hat Linux服务器配置与应用>第17章:Telnet.SSH和VNC服务的配置与应用.俗话说:“前人栽树,后人乘凉”.我懒得再照书本打一遍了,就从这里拷贝了一份 ...

  4. centos SSH配置详解

    基本概念  linux自带的ssh为OpenSSH ssh协议提供两种用户认证方式  1. 基于口令的安全认证:使用用户名.密码的方式对登录用户进行认证 2. 基于密钥的安全认证:使用公钥和私钥对的方 ...

  5. Telnet、SSH和VNC 区别

    Telnet Telnet是进行远程登录的标准协议,它是当今Internet上应用最广泛的协议之一.它把用户正在使用的终 端或计算机变成网络某一远程主机的仿真终端,使得用户可以方便地使用远程主机上的软 ...

  6. SSH概述与配置文件说明

    一.什么是SSH? 简单说,SSH是一种网络协议,用于计算机之间的加密登录.在出现SSH之前,系统管理员需要登入远程服务器执行系统管理任务时,都是用telnet来实现的,telnet协议采用明文密码传 ...

  7. .ssh/config 文件的解释算法及配置原则

    前言 SSH 是连接远程主机最常用的方式,尽管连接到耽搁主机的基本操作非常直接,但当你开始使用大量的远程系统时,这就会成为笨重和复杂的任务. 幸运的是,OpenSSH 允许您提供自定义的客户端连接选项 ...

  8. TCP Wrappers原理及简单实验

    1.TCP Wrappers(简易防火墙)简介TCP_Wrappers是一个工作在第四层(传输层)的的安全工具,对有状态连接(TCP)的特定服务进行安全检测并实现访问控制,界定方式是凡是调用libwr ...

  9. 老杜告诉你java小白到大神是怎么炼成的(转载)

    老杜告诉你java小白到大神是怎么炼成的 1. 学习前的准备 一个好的学习方法(应该怎么学习更高效): 一个合格的程序员应该具备两个能力 有一个很好的指法速度(敲代码快) 有一个很好的编程思想(编程思 ...

随机推荐

  1. 从头认识java-18.2 主要的线程机制(2)-Executors的使用

    在前面的章节我们都是直接对Thread进行管理,我们这里解释一下还有一个管理Thread的类Executors. 1.样例: package com.ray.ch17; import java.uti ...

  2. globalToLocal和localToGlobal

    官方API: groupOut全局坐标(50,50) gourpIn全局坐标(100,100),并嵌套在groupOut里 btn全局坐标(150,150),并嵌套在groupIn里 获取组件全局坐标 ...

  3. 谷歌浏览器chrome://inspect/#devices调试webview的页面和控制台布局错乱问题

    谷歌浏览器chrome://inspect/#devices调试webview的页面和控制台布局错乱问题 : 谷歌浏览器的版本过高,选择60版本即可: 版本 60.0.3080.5(正式版本)

  4. LeetCode 笔记系列八 Longest Valid Parentheses [lich你又想多了]

    题目:Given a string containing just the characters '(' and ')', find the length of the longest valid ( ...

  5. jquery树形菜单

    转自:http://keleyi.com/dev/3068696139522ae4.htm 代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1 ...

  6. [ Office 365 开发系列 ] 前言

    前言 本人从接触Microsoft SharePoint Server 2007到目前为止,已经在微软SharePoint的路上已经走了好几年,基于SharePoint平台的特殊性,对微软产品线都有了 ...

  7. R中利用SQL语言读取数据框(sqldf库的使用)

    熟悉MySQL的朋友可以使用sqldf来操作数据框 # 引入sqldf库(sqldf) library(sqldf) # 释放RMySQL库的加载(针对sqldf报错) #detach("p ...

  8. /proc/iomem和/proc/ioports对应的fops

    /proc/iomem和/proc/ioports对应的fops static int __init ioresources_init(void) {     struct proc_dir_entr ...

  9. librosa音频特征提取,python librosa库在centos上依赖llvm的问题?

    win10下安装使用: https://blog.csdn.net/qq_39516859/article/details/80679718 https://blog.csdn.net/qq_3951 ...

  10. pandas.read_csv() 部分参数解释

    read_csv()所有参数 pandas.read_csv( filepath_or_buffer, sep=',', delimiter=None, header='infer', names=N ...