搭建SSH框架 基本步骤
一:myeclipse 搭建
1.添加spring支持。
MyEclipse-->Add Spring...-->把AOP Core Web 三个libraries 复选上。 下一步 完成。
2.添加hibernate支持。
首先先打开myeclipse hibernate 视图 建立一个数据库连接。根据不同的数据驱动建立不同的数据库连接。
MyEclipse-->Add Hibernate...--> 根据需要 一步步完成。
3. 添加struts支持。
然后在web.xml文件里
<context-param>
<param-name>contexConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
再在 struts-config.xml中
<controller
processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
</controller>
这个时候加载项目会报一个确实pool包的错误。 然后到构建路径里去添加起来。
这时候 框架基本搭建好了。
eclipse 搭建SSH步骤
1.导入驱动包。。struts、spring、hibernate的包和数据库连接的驱动包。
2.配置 xml文件。。
3.添加struts-config.xml文件 其中涉及到引用dtd文件
4.添加applicationContext.xml文件 胚子该文件。。(1.连接。2 sessionfactory 3,假如连接字符是写在属性文件里,还要配
属性文件连接的bean)
5.实体映射用到hibernate的插件。(注意表得有主键,不然生成的xml文件有错。)
6.写dao类 biz类 action等
7 写JSP文件。
用eclipse搭建 主要得熟悉3个配置文件的配置。(web.xml 、struts-config.xml、applicationContext.xml)