eclipse整合SSH框架-配置Spring-集成SSH

2024-10-25 11:56:46

1、导入Spring的jar包。需要aop,beans,context,core,expression,jdbc,orm,tx,web以及导入spring和struts2集成包Struts2-spring-plugin-2.3.15.jar

eclipse整合SSH框架-配置Spring-集成SSH

2、所有需要的jar包,如下图所示。

eclipse整合SSH框架-配置Spring-集成SSH

3、下面需要把Hibernate的SessionFactory交给Spring去管理,配置文件如下。

eclipse整合SSH框架-配置Spring-集成SSH

4、再把Hibernate的配置文件注释掉,代码如下。

eclipse整合SSH框架-配置Spring-集成SSH

5、再配置web.xml,代码如下。

eclipse整合SSH框架-配置Spring-集成SSH

6、然后编写jsp页面,先创建一个student文件夹,再创建jsp文件。

eclipse整合SSH框架-配置Spring-集成SSH

7、jsp页面代码如下。

eclipse整合SSH框架-配置Spring-集成SSH

8、再编写StuAction,代码如下。

eclipse整合SSH框架-配置Spring-集成SSH

9、编写Service代码。

eclipse整合SSH框架-配置Spring-集成SSHeclipse整合SSH框架-配置Spring-集成SSH

10、编写Dao代码。

eclipse整合SSH框架-配置Spring-集成SSHeclipse整合SSH框架-配置Spring-集成SSH

11、把项目添加到tomcat,并启动。

eclipse整合SSH框架-配置Spring-集成SSH

12、启动浏览器,输入访问地址。

eclipse整合SSH框架-配置Spring-集成SSH

13、点击添加学生按钮,看看数据库和页面以及控制台的日志。

eclipse整合SSH框架-配置Spring-集成SSHeclipse整合SSH框架-配置Spring-集成SSHeclipse整合SSH框架-配置Spring-集成SSH
猜你喜欢