---
title: "SSH 整合笔记"
author: "toreking"
date: "2012-09-19T22:02:55Z"
tags: ["Hibernate", "Spring", "Struts", "整合"]
categories: ["企业架构"]
slug: "ssh"
draft: false
lastmod: "2012-09-19T22:09:09Z"
id: 1681828
url: "https://toreking.iteye.com/blog/1681828"
---

&lt;!-- \[if gte mso 9]&gt;&lt;xml&gt; &lt;o:OfficeDocumentSettings&gt; &lt;o:RelyOnVML/&gt; &lt;o:AllowPNG/&gt; &lt;/o:OfficeDocumentSettings&gt; &lt;/xml&gt;&lt;!\[endif]--&gt;

&lt;!-- \[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt; &lt;w:View&gt;Normal&lt;/w:View&gt; &lt;w:Zoom&gt;0&lt;/w:Zoom&gt; &lt;w:TrackMoves/&gt; &lt;w:TrackFormatting/&gt; &lt;w:PunctuationKerning/&gt; &lt;w:DrawingGridVerticalSpacing&gt;7.8 磅&lt;/w:DrawingGridVerticalSpacing&gt; &lt;w:DisplayHorizontalDrawingGridEvery&gt;0&lt;/w:DisplayHorizontalDrawingGridEvery&gt; &lt;w:DisplayVerticalDrawingGridEvery&gt;2&lt;/w:DisplayVerticalDrawingGridEvery&gt; &lt;w:ValidateAgainstSchemas/&gt; &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt; &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt; &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt; &lt;w:DoNotPromoteQF/&gt; &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt; &lt;w:LidThemeAsian&gt;ZH-CN&lt;/w:LidThemeAsian&gt; &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt; &lt;w:Compatibility&gt; &lt;w:SpaceForUL/&gt; &lt;w:BalanceSingleByteDoubleByteWidth/&gt; &lt;w:DoNotLeaveBackslashAlone/&gt; &lt;w:ULTrailSpace/&gt; &lt;w:DoNotExpandShiftReturn/&gt; &lt;w:AdjustLineHeightInTable/&gt; &lt;w:BreakWrappedTables/&gt; &lt;w:SnapToGridInCell/&gt; &lt;w:WrapTextWithPunct/&gt; &lt;w:UseAsianBreakRules/&gt; &lt;w:DontGrowAutofit/&gt; &lt;w:SplitPgBreakAndParaMark/&gt; &lt;w:EnableOpenTypeKerning/&gt; &lt;w:DontFlipMirrorIndents/&gt; &lt;w:OverrideTableStyleHps/&gt; &lt;w:UseFELayout/&gt; &lt;/w:Compatibility&gt; &lt;m:mathPr&gt; &lt;m:mathFont m:val="Cambria Math"/&gt; &lt;m:brkBin m:val="before"/&gt; &lt;m:brkBinSub m:val="&#45;-"/&gt; &lt;m:smallFrac m:val="off"/&gt; &lt;m:dispDef/&gt; &lt;m:lMargin m:val="0"/&gt; &lt;m:rMargin m:val="0"/&gt; &lt;m:defJc m:val="centerGroup"/&gt; &lt;m:wrapIndent m:val="1440"/&gt; &lt;m:intLim m:val="subSup"/&gt; &lt;m:naryLim m:val="undOvr"/&gt; &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;!\[endif]--&gt;&lt;!-- \[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true" DefSemiHidden="true" DefQFormat="false" DefPriority="99" LatentStyleCount="267"&gt; &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Normal"/&gt; &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="heading 1"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 1"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 2"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 3"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 4"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 5"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 6"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 7"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 8"/&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 9"/&gt; &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/&gt; &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Title"/&gt; &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/&gt; &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/&gt; &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Strong"/&gt; &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/&gt; &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false" UnhideWhenUsed="false" Name="Table Grid"/&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/&gt; &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/&gt; &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/&gt; &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Quote"/&gt; &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false" UnhideWhenUsed="false" Name="Light Shading Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false" UnhideWhenUsed="false" Name="Light List Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false" UnhideWhenUsed="false" Name="Light Grid Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false" UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false" UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/&gt; &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/&gt; &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/&gt; &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/&gt; &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/&gt; &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false" UnhideWhenUsed="false" QFormat="true" Name="Book Title"/&gt; &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography"/&gt; &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/&gt; &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;!\[endif]--&gt;&lt;!-- \[if gte mso 10]&gt; &lt;style&gt; /* Style Definitions \*/ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} &lt;/style&gt; &lt;!\[endif]--&gt;

**SSH** **整合笔记**

**1.** **加入** **struts2** **的环境**

    1.1 加入必须 jar 包

       *Commons-fileupload-\*.jar*

       *Freemarker-\*.jar*

       *Ognl-\*.jar*

       *Struts1-core-\*.jar*

       *Xwork-core-\*.jar*

    1.2 配置 web.xml, 将请求交给 struts 来处理

       &lt; filter &gt;

          &lt; filter-name &gt; s &lt;/ filter-name &gt;

         &lt; filter-class &gt; *org.apache.struts2.dispatcher.ng.*

*filter.StrutsPrepareAndExecuteFilter* &lt;/ filter-class &gt;

       &lt;/ filter &gt;

       &lt; filter-mapping &gt;

          &lt; filter-name &gt; s &lt;/ filter-name &gt;

          &lt; url-pattern &gt; /* &lt;/ url-pattern &gt;

       &lt;/ filter-mapping &gt;

   1.3 加入 struts.xml 文件

      ---- 加入 struts 的 tld 标签库引入

                |--- 在已经加入的 *struts2-core-\*.jar* 包 *struts-2.0.dtd* 中有

   1.4 写一个 Action, 并配置到 struts.xml 中

      ----com.xcz.action.UserAction

      ------------------------------------------------------------------

&lt; package name = *"struts"* extends = *"struts-default"* &gt;

         &lt; action name = *"userdo"* class = *"com.xcz.action.UserAction"* &gt;

            &lt; result name = *"index"* &gt; index.jsp &lt;/ result &gt;

         &lt;/ action &gt;

      &lt;/ package &gt;

      ------------------------------------------------------------------

 

**2.** **加入** **Hibernate** **的环境**

    2.1 加入必须的 jar 包

       *antlr-\*.jar//* *其他工具辅助包*

*commons-collection-\*.jar//* *必须的集合类工具包*

*dom4j-\*.jar//hibernate* *靠其读写* *xml* *配置文件*

*hibernate\*.jar//* *核心包*

*jta-\*.jar//jta* *规范包*

*db-connection-java-\*.jar//* *数据库连接包*

 

*//* *以下的包* *hibernate* *版本不一样，存在差异*

*javassist-\*.jar//* *字节码增强包（更高版本已经换成* *\[cglib.jar]+\[asm.jar]+\[asm-attrs.jar]* *）*

*slf4j-api-\*.jar//*

*slf4j-nop-\*.jar//*

    2.2 加入 hibernate.cfg.xml

       ---- 加入 hibernate 的 tld 标签库引入 ( 注意配置文件引入的 dtd 头，这里是 ***Hibernate Configuration*** DTD )

                |--- 在已经加入的 hibernate3.jar 包中 */org/hibernate/hibernate-configuration-3.0.dtd* 中有

    ----------------------------------------------------------------------------------------------

           &lt;! DOCTYPE hibernate-configuration PUBLIC

         "-//Hibernate/***Hibernate Configuration*** DTD 3.0//EN"

         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" &gt;

    ----------------------------------------------------------------------------------------------

---- 写入数据库连接属性

    -----------------------------------------------------------------------------------------------

       &lt; hibernate-configuration &gt;

         &lt; session-factory &gt;

            &lt; property name = *"hibernate.connection.driver\_class"* &gt; com.mysql.jdbc.Driver &lt;/ property &gt;

            &lt; property name = *"hibernate.connection.url"* &gt; jdbc:mysql://localhost :3306/db\_ssh &lt;/ property &gt;

            &lt; property name = *"hibernate.dialect"* &gt; org.hibernate.dialect.MySQLDialect &lt;/ property &gt;

            &lt; property name = *"hibernate.connection.username"* &gt; root &lt;/ property &gt;

            &lt; property name = *"hibernate.connection.password"* &gt; mysql &lt;/ property &gt;

            &lt; property name = *"show\_sql"* &gt; true &lt;/ property &gt;   

     

         &lt;/ session-factory &gt;

&lt;/ hibernate-configuration &gt;

\-----------------------------------------------------------------------------------------------

    2.3 写实体类 User( 多个对应一个 Derpartment) 、 Derpartment( 对应一个 Set&lt;User&gt;)

    2.4 在实体类的包下分别写 xml 映射文件 Xxxx.hbm.xml( 注意配置文件引入的 dtd 头，这里是 ***Hibernate Mapping*** DTD )

       User.hbm.xml

    ----------------------------------------------------------------------------------------------

       &lt;! DOCTYPE hibernate-mapping PUBLIC

      "-//Hibernate/***Hibernate Mapping*** DTD 3.0//EN"

      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" &gt;

 

&lt; hibernate-mapping &gt;

         &lt; class name = *"com.xcz.domain.User"* table = *"t\_user"* &gt;

            &lt; id name = *"id"* column = *"id"* length = *"36"* &gt;

               &lt; generator class = *"uuid.hex"* /&gt;

            &lt;/ id &gt;

     

            &lt; property name = *"username"* length = *"20"* /&gt;

            &lt; property name = *"password"* length = *"20"* /&gt;

            &lt;!—- 多对一指向 deptid ( 外键 )--&gt;

            &lt; many-to-one name = *"dept"* column = *"deptid"* class = *"com.xcz.domain.Department"* /&gt;

         &lt;/ class &gt;

&lt;/ hibernate-mapping &gt;

    ----------------------------------------------------------------------------------------------

       Derpartment.hbm.xml

    ----------------------------------------------------------------------------------------------

       &lt;! DOCTYPE hibernate-mapping PUBLIC

      "-//Hibernate/***Hibernate Mapping*** DTD 3.0//EN"

      "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" &gt;

 

&lt; hibernate-mapping &gt;

         &lt; class name = *"com.xcz.domain.Department"* table = *"t\_dept"* &gt;

            &lt; id name = *"id"* column = *"id"* length = *"36"* &gt;

               &lt; generator class = *"uuid.hex"* /&gt;

            &lt;/ id &gt;

     

            &lt; property name = *"dname"* length = *"50"* /&gt;

     

            &lt; set name = *"users"* inverse = *"true"* &gt; &lt;!-- 一对多 Set 集合属性配置 --&gt;

               &lt; key column = *"deptid"* /&gt;    &lt;!—column 就是 **多对一指向的属性** --&gt;

               &lt; one-to-many class = *"com.xcz.domain.User"* /&gt;

            &lt;/ set &gt;

         &lt;/ class &gt;

&lt;/ hibernate-mapping &gt;

    ----------------------------------------------------------------------------------------------

 

3\. 加入 Spring

    3.1 加入 Spring 的必须 jar 包以及整合的 jar 包

       *Aspectjrt.jar*

       *Aspectjweaver.jar*

       *Commons-loggin.jar*

       *Log4j-\*.jar*

       *Spring.jar*

       *Struts2-spring-plugin-\*.jar*

    3.2 配置 web.xml( 文件加载的时候 )

注：在 SSH 中，接收请求的 Servlet 是由 Struts 的 ActionServlet 来配置的，因此此时就不能够使用 DispatchServlet 来接受请求。为了能在此时能过加载 Spring 的 Bean 配置，可以在 Web.xml 中配置一个监听器，并通过 &lt;context-param&gt; 指定 xml 文件名。

      --------------------------------------------------------------------------------------------

&lt; context-param &gt;

          &lt; param-name &gt; contextConfigLocation &lt;/ param-name &gt;

          &lt;!-- ,classpath \*:applicationContext-\*.xml ,/WEB-INF/applicationContext\*.xml --&gt;

          &lt; param-value &gt; classpath \*:applicationContext\*.xml &lt;/ param-value &gt;

       &lt;/ context-param &gt;

 

       &lt; listener &gt;

       &lt; listener-class &gt; *org.springframework.web.context.ContextLoaderListener* &lt;/ listener-class &gt;

       &lt;/ listener &gt;

\--------------------------------------------------------------------------------------------

    3.3 添加 spring 的配置文件 applicationContext.xml

       注：加入配置文件引入的 dtd 头

\--------------------------------------------------------------------------------------------

       &lt; 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 = *"*

*htt* [*p://www.springframework.org/schema/beans* *ht*]() *tp://www.springframework.org/schema/beans/spring-beans-2.5.xsd*

         *http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd*

         *http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"* &gt;

     

      &lt;bean&gt;

\--------------------------------------------------------------------------------------------

    3.4 在 applicationContext\*.xml 中 SessionFactory 的配置

       注：配置 SessionFactory 对象，为 DAO 层提供 Hibernate 的数据库连接对象，其中需要注入 2.2 中配置的 DataSource 。

\--------------------------------------------------------------------------------------------

&lt; bean name = *"sessionFactory"* class = *"org.springframework.orm.hibernate3.LocalSessionFactoryBean"* &gt;

         &lt; property name = *"configLocation"* value = *"class:hibernate.cfg.xml"* /&gt;

&lt;/ bean &gt;

\--------------------------------------------------------------------------------------------

    3.5 在 applicationContext\*.xml 中配置事务

       注：为 SessionFactory 对象添加事务配置组件，并注入 3.3 中配置的 SessionFactory 对象。

\--------------------------------------------------------------------------------------------

&lt; bean name = *"transactionManager"* class = *"org.springframework.orm.hibernate3.HibernateTransactionManager"* &gt;

         &lt; property name = *"sessionFactory"* ref = *"sessionFactory"* &gt;&lt;/ property &gt;

&lt;/ bean &gt;

\--------------------------------------------------------------------------------------------

    3.6 编写 DAO

       注： *Dao* *需要继承* *HibernateDaoSupport*

\--------------------------------------------------------------------------------------------

        public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

 

           public void addUser(User user) {

              this.getHibernateTemplate().save(user);

           }

 

           public User getUser(String id) {

              return (User) this.getHibernateTemplate().get(User.class, id);

           }

 

           public void updateUser(User user) {

              this.getHibernateTemplate().update(user);

           }

   

           public User getByUsername(String username) {

              return (User) this.getSession().createQuery(

"from User where username = ?").setParameter(0, username).uniqueResult();

           }

}

\--------------------------------------------------------------------------------------------

    3.7 在 applicationContext\*.xml 中配置 DAO 中的 Bean ，并注入 SessionFactory

\--------------------------------------------------------------------------------------------

       &lt; bean id = *"userDao"* class = *"com.chinasofti.dao.impl.UserDaoImpl"* &gt;

         &lt; property name = *"sessionFactory"* &gt;

            &lt; ref bean = *"sessionFactory"* /&gt;

         &lt;/ property &gt;

      &lt;/ bean &gt;

\--------------------------------------------------------------------------------------------

    3.8 写一个 Action, 并配置到 applicationContext\*.xml ，并注入需要的类

\--------------------------------------------------------------------------------------------

&lt; bean id = *"userAction"* class = *"com.chinasofti.action.UserActoin"* scope = *"prototype"* &gt;

         &lt; property name = *"userService"* ref = *"userService"* /&gt;

         &lt; property name = *"departmentService"* ref = *"departmentService"* /&gt;

      &lt;/ bean &gt;

\--------------------------------------------------------------------------------------------