您好,欢迎来到微智科技网。
搜索
您的当前位置:首页SSH学习笔记(一)

SSH学习笔记(一)

来源:微智科技网

开发环境:1、MyEclipse 6.5

                    2、Tomcat 6.0

                    3、Struts2.0 + Hibernate3.2 + Spring2.0

一、编码前的操作

<Context path="/mytest" docBase="G:\workspace\ssh\mytest\WebRoot" reloadable="true" />

添加到项目的映射

4、使用MyEclipse自带的导入功能来整合。步骤如后几点。

5、选中项目mytest,在MyEclipse中,myeclipse->Project Capabilities->Add Hibernate Capabilities,在弹出的对话框中选中Hibernate 3.2,"JAR Library Installation"选择"Copy checked Library ....." 。如果不选copy的话,部署到Tomcat时会有class not found 。

6、一步步next,当到选择database connection时,因为我们的小项目采用spring来管理,所以不选"Specify database connection detail?",同理,也不选"Create SessionFactory calss?"。一直到最后,就增加了项目的Hibernate支持。

7、接下来增加项目对Spring的支持。选中项目mytest,在MyEclipse中,myeclipse->Project Capabilities->Add Spring Capabilities,在弹出的对话框中选中Spring 2.0,选择前4个Library和Spring2.0 web library,,"JAR Library Installation"选择"Copy checked Library ....." 。

9、手动添加对Structs的支持。使用的是structs 2.0.11。将(commons-logging-1.0.4.jar这个包spring带了,所以不用拷贝)freemarker-2.3.8.jar,ognl-2.6.11.jar,structs2-core-2.0.11.jar,structs2-spring-plugin-2.0.11.jar,xwork-2.0.4.jar拷贝到WEB-INF/lib/下。

<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> </struts>

项目采用的是Spring来管理,相当于action只是在structs中申明。
11、在WEB-INF/web.xml添加structs的过滤器。在<welcome-file-list>之上添加

<filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>

这样就添加了structs的支持。
12、在WEB-INF/web.xml中添加Spring的。在</web-app>之上添加

<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener>

做完这个之后就可以启动tomcat看看,应该没有任何问题。


到现在为止,整个项目已经添加好了ssh的支持了。

转载于:https://www.cnblogs.com/moiyer/archive/2011/08/09/2316169.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 7swz.com 版权所有 赣ICP备2024042798号-8

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务