《基于myEclipse的SSH框架搭建.docx》由会员分享,可在线阅读,更多相关《基于myEclipse的SSH框架搭建.docx(27页珍藏版)》请在第一文库网上搜索。
1、自己搭建一个SSH框架!真累挺!来源:张成法的日志1、实验环境准备MyEclipse8.6XTomcat6.0.20XMySQL5.1X数据库脚本程序入CREATE TABLE user (id int(ll) NOT NULL autojncrement,username varchar(50) default NULL,password varchar(50) default NULL,PRIMARY KEY (id);INSERT INTO user VALUES (T, admin, admin);环境的搭建这里就不写了,网上有很多这样的资料。2、开始搭建!打开MyEclipse,需要
2、注意的是这里应该处于MyEclipse Java Enterprise视图;新建一个Web Project,输入适当的工程名字,这里输入ssh, Finish即可。TH回区Project Name:sshJ2EE Specification Level0 Java EE 5.0。J2EE 1.40 J2EE 1.3MavenL j Add Maven supportLearr more about Mavec4MyEclipseJSTL Support匚 Add JSTL libraries to WEB-INF/lib folder?Cancel番 New Web ProjectCreate
3、 a Web ProjectCreate a web project in the workspace or an external locationWeb Project Details确定之后MyEclipse会生成名为SSH的项目,其中生成的目录结构如下所示:,高 ssh国srct JRE System Library Sun JDK 1,6.0_130 Jfe Java EE 5 Libraries/ 筵 WebRootl 爵 META-INF, WEB-INF后lib园 webjcml国 indexjsp3.添加StrutsL2框架支持在ssh工程上面右击,在弹出的菜单中选择MyEc
4、lipse - Add Struts Capabilities.,添加Struts的支持。NewGo IntoOpen in New WindowOpen Type HierarchyF4Show InAlt+ShiftsW 11CopyCtrl+CE一Copy Qualified Name二PasteCtrl+VXDeleteDeleteBuild PathSourceAlt+Shift+SRefactorAlt+Shift+T 垓Import.,dExport.$RefreshF5Close ProjectAssign Working Sets.Run AsDebug AsProfile
5、AsTeamCompare WithRestore from Local History.MyEclipseConfigurePropertiesAlt+Enter+ Open in ExplorerAdd and Remove Project Deployments.Add XFire Web Service Capabilities.Add REST Web Service Capabilities.Add Tapestry Capabilities.Add Struts Capabilities-Add Spring Capabilities.Add Report Capabilitie
6、s.Add Portlet Capabilities.Add JPA Capabilities.Add JSF Capabilities.Add JSTL LibrariesAdd Hibernate Capabilities.Run XDoclet二 Generate UML2 Class Diagram.Run ValidationExclude From ValidationManage Validation.-Remove All Validation Markers在弹出的对话框中选择Struts L2,修改Base package for new classes成所需的包名,其余保
7、持原状,Finish即可El?IQ Add Struts Capabilities完成后的结构为:/ J ssh, 四 src 限 com.zhang.struts 国 JRE System Library Sun JDK L6.0_13 N Java EE 5 Libraries0 喙 Struts 1.2 Libraries,B WebRoott & META-INF,& WEB-INF0 libT struts-bean.tld0 struts-config.xmlf struts-html.tldTJ struts-logic.tldT” struts-nested.tldd stru
8、ts-tiles.tld;Xj validator-rules.xml团 web.xmlindex.jsp4.添加SpringZ.O框架支持在ssh工程上面右击,在弹出的菜单中选择MyEclipse- Add Spring Capabilities.,添加Spring框架支持NewGo IntoF4Alt+Shift+W Ctrl+CCtrl+VDeleteAlt+ShiftAft+Shift+TOpen in New WindowOpen Type HierarchyShow InCopy西 Copy Qualified Name二 PasteX DeleteBuild PathSource
9、Refactor也 Import.d Export.软 RefreshClose ProjectAssign Working SetsRun AsDebug AsProfile Asit Open in ExplorerAdd and Remove Project Deployments-Add XAre Web Service Capabilities.Add REST Web Service Capabilities.Add Tapestry CapabilitiesAdd Spring Capabilities.Add Report Capabilities.Add Portlet Ca
10、pabilitiesAdd JPA Capabilities.Add JSF Capabilities.Add JSTL Libraries.Add Hibernate CapabilitiesRun XDodet二 Generate UML2 Class DiagramRun ValidationExclude From ValidationManage Validation.Remove All Validation MarkersTeamCompare WithRestore from Local History.O MyEdipseConfigurePropertiesAlt* Ent
11、er由于Spring采取最小化库发布的方式,使得Spring的库文件彼此都是分离的,因而我们需要自己选择需要的库,需要引用的如下图:Add Spring CapabilitiesI 回 ifyAdd Spring CapabilitiesAdd MyEclipse Spring and User libraries to projectSpring version: Spring 1.2 Spring 2.0 Spring 2.5 0 Spring 3.0Select the libraries to add to the buildpathShow: J MyEclipse Librarie
12、s ? User Libraries7 Spring 3.0 AOP Libraries - 1 Spring 3.0 Core Libraries - V Spring 3.0 Persistence Core Libraries - W Spring 3.0 Persistence JDBC Libraries - Spring 3.0 Persistence JDO Libraries - Spring 3.0 Persistence IBATIS Libraries - Spring 3.0 J2EE Libraries - 匚 Spring 3.0 Remoting Librarie
13、s - 亡Spring 3.0 Mise Library - ? Spring 3.0 Testing Support Libraries - 2 Spring 3.0 Web Libraries - Spring Security 3.0 - View and edit librariesJAR Library Installation0 Add checked Libraries to project build-pathCopy checked Library contents to project folder (TLDs always copied)Library Folder:Browse.Tag Library InstallationTag Library Folder: /WebRoot/WEB-INFBrowse.选择好后Next,在窗口中选择Browse,选择ssh工程下面的WEB-INF文件夹,然后Finsh。Add Spring Capabilities, 、,Add Spring bean configuration file13 Enable AOP