eclipse用ssh开发项目怎么搭建ssh框架

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
& & & & 在 MyEclipse 的“包资源管理器”中,单击鼠标右键,选择“新建”→“Web Project”:
& & & & 创建一个 Web 项目:
& & & & 点击新创建的 Web 项目,单击鼠标右键,选择“MyEclipse”→“Add Struts Capabilities ...”:
& & & & 选择“Struts 2.1”,单击“下一步”:
& & & & 勾选上“Struts 2 Spring Libraries - &MyEclipse-Library&”,点击“完成”:
& & & & 点击新创建的 Web 项目,单击鼠标右键,选择“MyEclipse”→“Add Spring Capabilities ...”:
& & & & 勾选上“Spring 3.1 Web Libraries - &MyEclipse-Library&”,单击“下一步”:
& & & & 点击“Browse”,定位到“WebRoot/WEB-INF”目录,点击“完成”:
& & & & 点击新创建的 Web 项目,单击鼠标右键,选择“MyEclipse”→“Add Hibernate Capabilities ...”:
& & & & 勾选上“Spring 3.1 Persistence Libraries - &MyEclipse-Library&”,单击“下一步”:
& & & & 选择“Spring configuration file (applicationContext.xml)”,单击“下一步”:
& & & & 选择“Existing Spring configuration file”,单击“下一步”:
& & & & 选择创建好的“DB Driver”,单击“下一步”:
& & & & 创建一个“java package”为“hb”,用来放置会话工厂类,点击“完成”:
& & & & 修改“web.xml”文件,添加以下代码:
& & & & 这是配置 Spring 监听器,通过添加该监听器,可以在 Web 项目启动时,查找 WEB-INF 目录下的 applicationContext.xml 配置文件,并通过配置文件来创建 Spring 容器。
&&&&&&& Spring 和 Hibernate 整合时,通常将事务交给 Spring 进行管理,因此,需要在 Spring 的配置文件 applicationContext.xml 中对事务进行配置,代码如下:
& & & & 注意,这里还需要在&beans&中添加“xmlns:aop”和“xmlns:tx”的命名声明:
& & & & 至此,SSH2 框架整合开发的环境就已经搭建完成。
阅读(23394)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'使用 MyEclipse 10 搭建 SSH2 框架整合开发环境',
blogAbstract:'\r\n& & & & 首先,创建数据库连接驱动,我这里选择的是 MySQL:\r\n\r\n\r\n\r\n& & & & 在 MyEclipse 的“包资源管理器”中,单击鼠标右键,选择“新建”→“Web Project”:\r\n\r\n\r\n\r\n& & & & 创建一个 Web 项目:',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:6,
publishTime:9,
permalink:'blog/static/',
commentCount:7,
mainCommentCount:4,
recommendCount:3,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'0',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}搭建一个SSH项目框架的步骤_MySQL_ThinkSAAS
搭建一个SSH项目框架的步骤
搭建一个SSH项目框架的步骤
内容来源: 网络
1、导入包(个)
2、配置文件
applicationContext,xml (beans.xml) 
(数据源、、事务管理器、事务通知、切面、组件扫描、对注解提供支持
Struts.xml
3,web.xml
Struts2过滤器
&filter&
&filter-name&action&/filter-name&
&filter-class&org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
&/filter-class&
&/filter&
Spring 的监听器
&context-param&
&param-name&contextConfigLocation&/param-name&
&param-value&classpath:
&/context-param&
&!--配置框架的上下文载入监听器
&listener&
&listener-class&org.springframework.web.context.ContextLoaderListener
&/listener-class&
&/listener&
数据源配置:
&bean id="dataSource" class="com.mchange.boPooledDataSource"&
&property name="driverClass" value="${driverClass}"&&/property&
&property name="jdbcUrl" value="${jdbcUrl}"&&/property&
&property name="user" value="${user}"&&/property&
&property name="password" value="${password}"&&/property&
&property name="initialPoolSize" value="${initialPoolSize}"&&/property&
&property name="maxPoolSize" value="${maxPoolSize}"&&/property&
&property name="minPoolSize" value="${minPoolSize}"&&/property&
&/bean&
Jdbc.properties
MySQL:
driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/数据库名
user=root
password=root
initialPoolSize=30
maxPoolSize=50
minPoolSize=30
SqlServer:
jdbc.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.url=jdbc:jtds:sqlserver://localhost:1433/数据名
jdbc.username=sa
jdbc.password=abc123
initialPoolSize=30
maxPoolSize=50
minPoolSize=30
Oracle:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:orcale:thin://localhost:1521/数据库名
jdbc.username=wapcms
jdbc.password=wapcms
PHP开发框架
开发工具/编程工具
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
让ThinkSAAS更好,把建议拿来。
开发客服微信My Eclipse 怎么搭建 SSH 框架_myeclipse吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:18,313贴子:
My Eclipse 怎么搭建 SSH 框架收藏
我一打开就是这样的 ,请问大神们这样的应该这么搭建SSH
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或4520人阅读
Java开发(4)
在上篇博客里,我简单介绍了Tomcat滴配置与Struts2滴搭建,如果对这个还不会滴童鞋去看一下我滴上篇博客。今天我们接着上篇博客滴内容,继续搭建我们滴SSH框架。
(一)在上篇博客滴基础上整合Spring:
首先我们把Spring所需要的jar(上篇博客有),复制到WebContent下的WEB-INF下的lib里面。其次在src下创建名为:applicationContext.xml文件。(有些人提示在WEB-INF下创建)个人建议:在src下创建。
Spring配置文件有两种格式:DTD格式;Schema格式。
基于DTD格式的配置文件格式如下:
&?xml version="1.0" encoding="UTF-8"?&
&!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"/dtd/web-app_2_3.dtd"&
id="loginService" class="com.hy.service.impl.LoginServiceImpl" /&
Schema格式的配置文件拥有自己的命名空间,格式如下:
&?xml version="1.0" encoding="UTF-8"?&
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:context="http://www.springframework.org/schema/context" 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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&
id="loginService" class="com.hy.service.impl.LoginServiceImpl" /&
这里我用的是第二种配置方式。applicationContext.xml内容为:
&?xml version="1.0" encoding="UTF-8"?&
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&
id="loginService" class="com.hy.service.impl.LoginServiceImpl" /&
id="loginServer" class="com.hy.action.LoginAction" scope="prototype"&
name="loginService" ref="loginService"&&
在struts里面这样配置就可以了:
name="struts2" extends="struts-default"&
name="Login" class="loginServer"&
name="success"&/result.jsp&
name="input"&/login.jsp&
这里要注意的是在struts.xml文件里面的action配置中,class=”“与我们上篇博客讲的Struts搭建不一样了。这里的class内容与applicationContext.xml里面的Action配置bean的id是相同的!!!
其次在web.xml我们需要在添加下面这些代码:
&contextConfigLocation&
&/WEB-INF/applicationContext*.xml,classpath*:applicationContext*.xml&
&org.springframework.web.context.ContextLoaderListener&
这样集成Spring所要配置的文件算是结束了,还有一点要强调整合Struts与Spring需要一个jar(struts2-spring-plugin-2.3.8.jar),这个jar我放到了struts2所需jar里面了,添加了这个jar才算把Struts与Spring整合在一起了。
在集成Hibernate前,说一下关于Spring XML文件上下文配置问题。applicationContext.xml其实这个文件可以保存到classpath或者WEB-INF文件下。随着项目增大,Spring的配置文件也会变得庞大,可以根据已定的原则分为几个配置文件,从而使配置更加清晰,提高可维护性。上面代码中的写法是查找classpath和WEB-INF文件下所有的配置文件(好多人都说了其中一种,如果写的查找和文件保存位置不一样,就会报错哦~)。
测试一下,整合情况,效果图如下:
莫急哈~~demo我会在下面给大家,请大家看清里面的网址,因为这个demo里面也包括最后SSH的搭建测试。
(二)集成Hibernate
首先还是把Hibernate所需要的jar(上篇博客有),复制到WebContent下的WEB-INF下的lib里面。然后在applicationContext.xml中添加下面的配置:
id="dataSource" class="mons.dbcp.BasicDataSource"
destroy-method="close"&
name="driverClassName" value="com.mysql.jdbc.Driver" /&
name="url" value="jdbc:mysql://localhost:3306/test" /&
name="username" value="root" /&
name="password" value="" /&
id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&
name="dataSource"&
bean="dataSource" /&
name="hibernateProperties"&
key="hibernate.dialect"&
org.hibernate.dialect.MySQLDialect
key="hibernate.hbm2ddl.auto"&update&
key="hibernate.connection.autocommit"&true &
key="hibernate.show_sql"&true&
key="sql_format"&true&
name="mappingResources"&
&com/hy/entity/User.hbm.xml&
到这里框架就算搭建完毕了。有人会有疑惑,不是要创建hibernate.cfg.xml或者hibernate.properties配置嘛,其实在上面的配置文件中,你是不是发现有一个bean中的文件特别像这两个文件中的内容嘛,其实这样就可以了,不用再创建那两个文件了。
在此说明一下如果你的数据库是MySQL配置按照上面那种方式配置,别忘了添加对应的jar(有人告诉我:jar包也要与自己的数据版本对应,否则连不上)。如果你的数据库是Oracle,配置按照下面图中进行配置。
最后在说一下Hibernate映射文件(类与表之间的关系映射)
name="类名" table="表名"&
name="主键名"&
name="主键列" /&
class="生成策略" /&
name="属性名" type="数据类型"&
name="列名" length="长度" not-null="是否不为空" /&
测试一下,效果图:
搭建SSH到这里就结束啦,如有疑问,请给我留言~~
近期有小伙伴反映,看了偶滴博客然后跟着做还是报错,总结了他们的错误这里我简单说明一下:
1.如果亲还没有配置Spring,就不要把(struts2-spring-plugin-2.3.8.jar),这个jar包提前导入到项目里(这是我滴错,把这个jar包放到struts所需的包包里面了),如果按我的博客验证struts时出错,那就把这个包删除即可。(整合Spring别忘了导入哦~)
2.就是配置问题:(上图,有图有真相~)
配置文件和代码里面的名字要对应,不然就出错哦~
3.就是我们的框架用到Hibernate,童鞋们都知道写映射表,但是别忘了配置文件中指定。
最后附上:
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:39049次
排名:千里之外
原创:26篇
评论:276条
Android 交流群:
Android RN交流群:
(2)(3)(1)(1)(3)(2)(1)(4)(4)(4)(4)-------------
新增文件夹...
新增文件夹
(多个标签用逗号分隔)
eclipse下搭建ssh框架详解.pdf
eclipse下搭建ssh框架详解。SSH 为 struts+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架。&br&
集成SSH框架的系统从职责上分为四层:表示层、业务逻辑层、数据持久层和域模块层,以帮助开发人员在短期内搭建结构清晰、可复用性好、维护方便的Web应用程序。其中使用Struts作为系统的整体基础架构,负责MVC的分离,在Struts框架的
eclipse下搭建ssh框架详解。SSH 为 struts+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架。&br&
集成SSH框架的系统从职责上分为四层:表示层、业务逻辑层、数据持久层和域模块层,以帮助开发人员在短期内搭建结构清晰、可复用性好、维护方便的Web应用程序。其中使用Struts作为系统的整体基础架构,负责MVC的分离,在Struts框架的模型部分,控制业务跳转,利用Hibernate框架对持久层提供支持,Spring做管理,管理struts和hibernate。具体做法是:用面向对象的分析方法根据需求提出一些模型,将这些模型实现为基本的Java对象,然后编写基本的DAO(Data Access Objects)接口,并给出Hibernate的DAO实现,采用Hibernate架构实现的DAO类来实现Java类与数据库之间的转换和访问,最后由Spring做管理,管理struts和hibernate。
加载中...!如果长时间没有加载,请刷新页面
下载本文档需要登录,并付出相应积分()。
文件大小:887.72 KB
所需积分:& 6
相关资讯  — 
相关讨论话题  — 
浏览:2764次&& 下载:0次
上传时间: 09:47:04
同类热门文档
0次浏览 &41次下载
7997次浏览 &6次下载
14553次浏览 &11次下载
17486次浏览 &10次下载
4727次浏览 &5次下载
8592次浏览 &0次下载
相关经验 -
& 2人评&3页
& 2人评&15页
& 9人评&11页
& 4人评&32页
& 0人评&4页
OPEN-OPEN, all rights reserved.}

我要回帖

更多关于 搭建ssh框架的步骤 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信