S2SH整合以及图片上传(1)之spring搭建
2018-03-04 16:29
537 查看
如若转载,请说明出处:http://blog.csdn.net/z1826378013/article/details/79437134
相关jar包下载
本套文章项目源码下载在本套文章的最后一篇文章结尾处:S2SH整合以及图片上传项目下载链接
关于S2SH,主要是struts2+spring+hibernate开发。
对于S2Sh整合开发来说,一个具体的操作流程,能够有效地解决一些由于粗心而造成的问题。
此处我采用的流程是spring --> hibernate --> struts2.
其中对应各个开发框架的版本为:spring4.3.14,hibernate4.3.11,struts2.3.32,mysql5.0.4。
首先,我们先来搭建第一个框架,spring。
第一步,在IDE开发环境中新建一个web项目,如下所示:
第二步,在新建的web项目的/TestUpload/WebRoot/WEB-INF/lib目录中,粘贴如下图所示的spring的开发jar包:
第三步,编写一个applicationContext.xml文件,放置到src目录下,其中的内容如下:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置测试bean -->
</beans> 第四步,在src目录下,新建一个测试用的包,在其中编写两个类,TestPojo以及TestSSH:
TestPojo内容如下所示:
package com.ssh.test;
public class TestPojo {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
TestSSH内容如下所示:package com.ssh.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestSSH {
public static void main(String[] args) {
//获取applicationContext
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
TestPojo testPojo = (TestPojo) ac.getBean("testPojo");
System.out.println(testPojo.getName());
}
}
接着要在applicationContext.xml中配置一个bean用来进行测试:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置测试bean -->
<bean id="testPojo" class="com.ssh.test.TestPojo">
<property name="name" value="Test Spring" />
</bean>
</beans> 在上面配置的bean中,配置TestPojo的name属性的值为Test Spring,方便后续测试。
第五步,测试spring,结果如下,则成功配置好了spring:
S2SH整合以及图片上传(2)之hibernate搭建(1)
相关jar包下载
本套文章项目源码下载在本套文章的最后一篇文章结尾处:S2SH整合以及图片上传项目下载链接
关于S2SH,主要是struts2+spring+hibernate开发。
对于S2Sh整合开发来说,一个具体的操作流程,能够有效地解决一些由于粗心而造成的问题。
此处我采用的流程是spring --> hibernate --> struts2.
其中对应各个开发框架的版本为:spring4.3.14,hibernate4.3.11,struts2.3.32,mysql5.0.4。
首先,我们先来搭建第一个框架,spring。
第一步,在IDE开发环境中新建一个web项目,如下所示:
第二步,在新建的web项目的/TestUpload/WebRoot/WEB-INF/lib目录中,粘贴如下图所示的spring的开发jar包:
第三步,编写一个applicationContext.xml文件,放置到src目录下,其中的内容如下:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置测试bean -->
</beans> 第四步,在src目录下,新建一个测试用的包,在其中编写两个类,TestPojo以及TestSSH:
TestPojo内容如下所示:
package com.ssh.test;
public class TestPojo {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
TestSSH内容如下所示:package com.ssh.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestSSH {
public static void main(String[] args) {
//获取applicationContext
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
TestPojo testPojo = (TestPojo) ac.getBean("testPojo");
System.out.println(testPojo.getName());
}
}
接着要在applicationContext.xml中配置一个bean用来进行测试:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- 配置测试bean -->
<bean id="testPojo" class="com.ssh.test.TestPojo">
<property name="name" value="Test Spring" />
</bean>
</beans> 在上面配置的bean中,配置TestPojo的name属性的值为Test Spring,方便后续测试。
第五步,测试spring,结果如下,则成功配置好了spring:
S2SH整合以及图片上传(2)之hibernate搭建(1)
相关文章推荐
- S2SH整合以及图片上传(3)之hibernate搭建(2)
- S2SH整合以及图片上传(5)之struts2的搭建
- S2SH整合以及图片上传(7)之解决懒加载
- S2SH整合以及图片上传(9)之删除图片
- S2SH整合以及图片上传(12)之分页显示
- S2SH整合以及图片上传(10)之修改信息(1)
- S2SH整合以及图片上传(6)之图片上传
- S2SH整合以及图片上传(8)之显示图片
- S2SH整合以及图片上传(11)之修改信息(2)
- Spring 使用七牛云存储上传图片以及html5图片压缩上传
- Spring+SpringMVC+MyBatis+easyUI整合优化篇(七)图片上传功能
- java S2SH项目框架Struts2.3+Spring3.1+Hibernate3.6框架搭建整合以及实例demo代码分享
- 最新spring boot搭建,整合jsp页面以及打war包配置
- Spring中文件上传,图片上传以及回显
- 快速搭建springboot框架以及整合ssm+shiro+安装Rabbitmq和Erlang、Mysql下载与配置
- redis集群搭建以及和spring整合
- springBoot整合ftp上传图片功能
- Spring+SpringMVC+MyBatis+easyUI整合优化篇(七)图片上传功能
- Spring+SpringMVC+Mybatis整合百度富文本编辑器Ueditor,上传图片到阿里云OSS对象存储。
- struts2+Hibernate4+spring3+EasyUI环境搭建之三:引入sututs2以及spring与sututs2整合