首页 ssh框架搭建流程(SSH framework build process)

ssh框架搭建流程(SSH framework build process)

举报
开通vip

ssh框架搭建流程(SSH framework build process)ssh框架搭建流程(SSH framework build process) ssh框架搭建流程(SSH framework build process) First, the traditional use of the spring configuration file is divided into four parts: spring_db.xml, spring_dao.xml, spring_action.xml, spring_service.xml, Dao, service and actio...

ssh框架搭建流程(SSH framework build process)
ssh框架搭建流程(SSH framework build process) ssh框架搭建流程(SSH framework build process) First, the traditional use of the spring configuration file is divided into four parts: spring_db.xml, spring_dao.xml, spring_action.xml, spring_service.xml, Dao, service and action are each to write in the configuration file, the basic steps are as follows: 1. first, build a new WebProject and try to select the Java version 2. add struts to project (before adding a DB connection to MyEclipse, to facilitate subsequent dataSource and Hibernate configuration) Notice the path to modify the package, change the yourcompany to the desired path, and the struts-config.xml path: /WEB-INF/struts-config.xml 3. add hibernate for project Hibernate package selection, according to the needs of the project, the general default can be; To add note, it's better to wrap the package JAR selection: copy, checked, Library... Mode, and copy all the JAR packages into the project /WebRoot/WEB-INF/lib path; The hibernate.cfg.xml file and the HibernateSessionFactory file that you want to set up are free to place. Finally, you can delete the entire frame after you've finished building it DateSource configuration, you can use the DataBase interface created at MyEclipe, or to fill in their own; 4. add spring for project The selection of Hibernate packages is added to the project itself as required by the general J2EE project: Spring AOP Library Spring Core Library Spring Persistence Core Library Spring Persistence JDBC Library Spring J2EE Library Spring, Testing, Support, Library (uncheck test test) Spring Web Library Sometimes the following two jar packages are automatically selected, so the following two jar are recommended: Hibernate 3.3, Core, Library Hibernate 3.3 Annotations & Entity Manager To add JAR, note that it's best to wrap the package JAR selection: copy, checked, Library... Mode, and copy all the JAR packages into the project /WebRoot/WEB-INF/lib path; ApplicationContext.xml file configuration path: under /WebRoot/WEB-INF, you can configure your file name according to custom, such as: spring.xml SessionFactory configuration location: applicationContext.xml (spring.xml), do not modify 5. modify the file generated by spring (spring.xml or applicationContext) Delete the sessionFactory in the XML configuration file, add the dateSource and sessionFactory in the spring framework (the name is best to use sessionFactory, or else the subsequent configuration is cumbersome) Configure, for example: org.hibernate.dialect.mysqldialect < > <道具键=“show_sql”>真的< /道具> <道具> <属性> <属性名称=“mappingresources”> <~——******************** (此处为配置坡映射文件)********************* --> <目录> <值>的COM / xasxt /演示/订单/客户。HBM。XML <值> <值>的COM / xasxt /演示/宝/ questiondesign。HBM。XML <值> <值>的COM / xasxt /演示/宝/ questionoption。HBM。XML <值> <值>的COM / xasxt /演示/宝/ questionsubject。HBM。XML <值> <值>的COM / xasxt /演示/宝/ staffinfo。HBM。XML <值> <值>的COM / xasxt /演示/宝/ surveyplan。HBM。XML <值> <值>的COM / xasxt /演示/宝/调查报告。HBM。XML <值> <列 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf > <属性> < bean > 6。进入myeclipe的数据库界面,查看添加的数据库连接,使用Hibernate逆向进行坡和弹簧刀的反转 这时,Hibernate自动生成的道文件会配置到弹簧生成的文件中; 7。修改XML文件网站。 添加: (1)。上下文参数 <语境参数> <参数名> contextconfiglocation < /参数名称> <参数值>:/ spring_ *。XML < /参数值>(这个文件就是弹簧生成的那个文件路径,名字不固定,看自己的配置) < /上下文参数> (2)过滤器 <过滤> <名称> < / OsIV过滤器过滤器名称> <过滤器类> org。springframework. ORM。hibernate3.支持。OpenSessionInViewFilter过滤器类> < / <过滤器> <筛选器映射> <名称> < / OsIV过滤器过滤器名称> < URL模式> <~——使用DWR框架的时候,必须要保证会话处于开启状态,所以 要添加一个路径--> < URL模式> / DWR /* < / URL模式> <筛选器映射> (3)听众 <听众> <监听器类> org。springframework.网站。语境。ContextLoaderListener监听器类> < / <听众> (4)。添加DWR框架, 8。添加DWR框架: (1)。修改XML中如下网站: 为XML添加servlet: <~——DWR框架内容开始--> <程序> <名> DWR servlet调用servlet的名字> < < servlet类> org。directwebremoting。servlet。DwrServlet < / servlet类> ,init-param, <名称> <参数调试/参数名称> <参数值>真的< /参数值> < /初始化参数> <启动时加载>启动时> 1加载> < > < servlet映射> <名> DWR servlet调用servlet的名字> < < URL模式> / DWR /* < / URL模式> <映射> <~——DWR框架内容结束--> (2)。在/根/ WEB-INF下添加dwr. xml,文件内容如下: <,xml version=“1”encoding=“utf-8”,> <~DOCTYPE DWR公共 “/ getahead有限公司/ / DTD Direct Web Remoting 2 / EN” “HTTP:/ / getahead。org / DWR / dwr20 DTD”> (3) the DWR configuration can be referred to as follows: DWR configuration Jar packages needed: Commons-logging.jar Dwr.jar You need to configure web.xml myDwr org.directwebremoting.servlet.DwrServlet debug true myDwr /dwr/* Prepare the Java class Create dwr.xml under WEB-INF (name not changed); < DOCTYPE, DWR, PUBLIC, "-//GetAhead, Limited//DTD, Direct, Web, Remoting, 3.0//EN."" "; > When a custom object is returned in the return value, the following configuration is added to the allow, that is, the path to the object added, equivalent to import JavaScript 9., at this time you can divide the spring.xml file into four, such as: Add things to spring_db.xml: In spring_service.xml, the corresponding service configuration is as follows: <属性名称=“目标”作为“clientservicetarget”> <属性> <属性名称=“transactionManager”ref=“TM”> <属性> <属性名称=“transactionattributes”> <道具>~—— 下面使用的事务传播行为字符串,如:propagation_required可以使用 org。springframework.交易。想要的字符串常量 TransactionDefinition。 --> <道具键=“添加”> propagation_required /道具> < <道具键=“找到”> propagation_required,只读/道具> < <道具键=“*”> propagation_required /道具> < <道具> <属性> < bean > <~——代理对象,如果要改变使用的业务方式,只需要改变类配置--> <属性名称=“staffinfodao“ref =“staffinfodao”/> <属性名称=“clientdao“ref =“clientdao”> <属性> < bean > 在spring_dao XML相应的道配置如下: <~——使用Hibernate生成坡和道时自动生成的道配置--> <属性名称=“sessionFactory”> ,参考豆=“sessionFactory”> <参考> <属性> < bean > 10。为弹簧添加行动处理过程: (1)。在struts_config。XML相应的添加如下(将其放在信息资源配置上面): <控制器processorclass =“org。springframework.网站。Struts。delegatingrequestprocessor”> < /控制器> (2)。添加某一行动后struts_config XML文件配置如下: <动作路径=“登录”type=“COM。xasxt。演示。网。Struts。行动。loginaction”> <转发名称=“loginfail”路径=“/ loginfail .jsp”/> <动作> 相应的在spring_action XML文件中配置如下: <豆名称=“/登录”class=“COM。xasxt。演示。网。Struts。行动。loginaction”> <~——注意名字与路径要相同--> <属性名称=“客服”ref=“客服”> <属性> < bean > 11。另外要注意,使用弹簧注入时,必须要有集、得到 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 ,而且,对于在弹簧中配置的类,不能直接新调用,可以使用getBean(“*”)来调用 12。当全部的配置都搞定后,可以启动服务,看看是否报错,如有错则说明某处配置有问题,当无误后框架即可使用 13。对于jQuery框架,在页面的配置如下: <脚本src=“jquery-1.4.2.版”> < /脚本> <脚本src=“/ jquery-ui-1.8。自定义/ JS / jquery-ui-1.8。习俗。js“> < /脚本> <链接href =“/ jquery-ui-1.8。自定义/ CSS /平滑/ jquery-ui-1.8。自定义CSS”rel=“stylesheet”type=“文本/ CSS”/> 14。当需要测试所建工程时,例子如下: 包com.xasxt.test; 进口java.util.hashset; 进口javax.annotation.resource; 进口org.junit.test; 进口org.junit.runner。 若; 进口org.springframework.test.context.contextconfiguration; 进口 org.springframework.test.context.junit4.springjunit4classru nner; 进口com.xasxt.demo.po.staffinfo; 进口com.xasxt.demo.po.staffinfodao; “在(springjunit4classrunner。类)/ ******************************************这一行配置固定 “contextconfiguration(位置= {“文件:Webroot公司/网站INF / spring_ *。XML”})/ ***********这一行配置与文件路径有关 公共课 试题 中考模拟试题doc幼小衔接 数学试题 下载云南高中历年会考数学试题下载N4真题下载党史题库下载 { “资源/ *********************************************************** *****这样就可以自动注入 StaffinfoDAO staffinfoDAO; @测试/ *********************************************************** *********测试方法必须添加此注解,这样才可以测试方法 testdao() { public void staffinfodao。保存(新staffinfo(2,“法”,56、“S”、“自由”、“ddsfa”、“123”、“1236。com”,新hashset(),新hashset(),新hashset(),新hashset())); } } 二、如果不通过传统的拆分四个弹簧文件进行配置,使用注解完成,则不需要添加spring_dao。XML、spring_action。XML、spring_service。XML这三个文件,只需要在道、服务实现类、行动中添加注解,并为spring_db.xml文件添加一些配置即可。 方法如下: 1配置SessionFactory。 在配置XML文件时春天: <豆 xmlns =“; xmlns:XSI =“; xmlns:P =“http:/ / www.springframework。org /模式/ P / *上面这几句默认会给 xmlns:AOP =“http:/ / www.springframework。org /模式/ AOP”/ *******下面三句意为配置文件中使用到的豆标签或包含的内容 xmlns:Tx =“; xmlns:上下文 =“; 场景:“ 下面三句意为配置文件中使用到的豆标签或包含的内容 “默认自动装配=“别名”> <~——意为使用默认的ID识别器,如 默认persondao类的豆配置为id =“persondao”,定义使用的时候 要写为:@资源(回车)persondao persondao;--> <上下文:注释< < >~——意为使用注解--> <背景:基础包=“COM组件扫描。bugmanager”/> <~——意为使用 注解的范围--> 2。 Spring declarative transaction processing and AOP configuration business classes The following three configurations mean adding transactions to all business classes: 3. annotation configuration: Configure annotations (@Resource....) Add annotations to the DAO class: @Repository Add annotations to the biz (service) interface implementation class: @Service Add annotations to the built-in DAO object in the biz (service) interface implementation class: @Resource Action generated class before adding notes: @Controller (value= /aaa) which is Action / * value, path * / Add annotations to the biz (service) object in the class that is generated by Action: @Resource 4. other parts refer to the above configuration. Three, SSH framework build process method two: 1. create a database db link 2. add Hibernate 3. add spring 4.Hibernate reverse engineering 5. configure sessionFactory When configuring the spring.xml file: personDAO; 6. configure dataSource 7. configuration annotations (@Resource....) Add annotations to the DAO class: @Repository Add annotations to the biz (service) class: @Service Add annotations to the DAO object that is built-in in the biz (service) class: @Resource Action generated class before adding notes: @Controller (value= /aaa) which is Action / * value, path * / Add annotations to the biz (service) object in the class that is generated by Action: @Resource 8.spring declarative handling of things The following three configurations mean adding transactions to all business classes: The 9.AOP configures the business class (see configuration above) 10. add struts, and integrate struts and spring 11. add Spring Sercurity, specific steps refer to documents written in PPT and 12. add DWR 13., adding JQuery is actually a process of drawing files
本文档为【ssh框架搭建流程(SSH framework build process)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_654168
暂无简介~
格式:doc
大小:51KB
软件:Word
页数:19
分类:生活休闲
上传时间:2018-02-21
浏览量:32