java web开发入门七(mybatis)基于intellig idea
mybatis
一、 入门开发步骤
1.导入相关jar包
mybatis3.4.2核心开发包
asm-5.1.jar
cglib-3.2.4.jar
commons-logging-1.1.3.jar
log4j-1.2.17.jar
mybatis-3.4.2.jar
mysql驱动包
mysql-connector-java-5.1.7-bin.jar
2.定义实体及实体映射文件
定义member实体
package com.eggtwo.entity; import java.math.BigDecimal;
import java.util.Date; public class Member {
private int id; public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} private String name;
private int age;
private Date birthday;
private boolean man;
private BigDecimal score; public BigDecimal getScore() {
return score;
} public void setScore(BigDecimal score) {
this.score = score;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public int getAge() {
return age;
} public void setAge(int age) {
this.age = age;
} public Date getBirthday() {
return birthday;
} public void setBirthday(Date birthday) {
this.birthday = birthday;
} public boolean isMan() {
return man;
} public void setMan(boolean man) {
this.man = man;
}
}
定义MemberMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="memberDao">
<!--
*******当实体属性和表字段名称一致的话resultMap标签可以省略********
resultMap标签:映射实体和表关系
id:映射关系id,要唯一
type:实体全路径
-->
<resultMap id="memberMap" type="com.eggtwo.entity.Member">
<!--id:映射主键属性
result:映射非主键属性
property:实体属性名称
column:表字段名称
-->
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="age" column="age"/>
<result property="birthday" column="birthday"/>
<result property="man" column="man"/>
<result property="score" column="score"/>
</resultMap> <insert id="add" parameterType="com.eggtwo.entity.Member" useGeneratedKeys="true" keyProperty="id">
insert into t_member(name,age,birthday,man,score)
values(#{name},#{age},#{birthday},#{man},#{score})
</insert> <update id="update" parameterType="com.eggtwo.entity.Member">
update t_member set
name = #{name},
age = #{age},
birthday = #{birthday},
man = #{man},
score = #{score}
where id = #{id}
</update> <delete id="delete" parameterType="int">
delete from t_member where id = #{id}
</delete> <!-- <select id="getById" parameterType="int" resultType="com.eggtwo.entity.Member">-->
<!--resultType使用mybatis.xml中设置的别名,这样可以简化难度-->
<select id="getById" parameterType="int" resultType="memberEntity">
select id,name,age,birthday,man,score
from t_member
where id=#{id}
</select>
<!--
理论上resultType的值应该是:List<com.eggtwo.entity.Member>
实际上只需要写List集合中的类型就可以
-->
<select id="getAll" resultType="com.eggtwo.entity.Member">
select *
from t_member
</select>
<!--分页:多参数的写法-->
<select id="getPageList" parameterType="map" resultType="com.eggtwo.entity.Member">
select id,name,age,birthday,man,score
from t_member limit #{start},#{size}
</select>
</mapper>
3.定义mybatis.cfg.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 加载类路径下的属性文件 -->
<!--加载数据库连接配置信息-->
<properties resource="jdbc.properties"/>
<!-- 设置类型别名 -->
<typeAliases>
<!--设置实体类Member的别名:memberEntity-->
<typeAlias type="com.eggtwo.entity.Member" alias="memberEntity"/>
</typeAliases> <!-- 设置一个默认的连接环境信息 -->
<environments default="mysql_developer"> <!-- 连接环境信息,取一个任意唯一的名字 -->
<environment id="mysql_developer">
<!-- mybatis使用jdbc事务管理方式 -->
<transactionManager type="jdbc"/>
<!-- mybatis使用连接池方式来获取连接 -->
<dataSource type="pooled">
<!--配置与数据库交互的4个必要属性 -->
<!-- 直接配置方式,不推荐-->
<!--<property name="driver" value="com.mysql.jdbc.Driver"/>-->
<!-- <property name="url" value="jdbc:mysql://127.0.0.1:3306/test"/>-->
<!--<property name="username" value="root"/>-->
<!-- <property name="password" value="123456"/>--> <!--直接在jdbc.properties文件中配置连接-->
<property name="driver" value="${mysql.driver}"/>
<property name="url" value="${mysql.url}"/>
<property name="username" value="${mysql.username}"/>
<property name="password" value="${mysql.password}"/> </dataSource>
</environment> </environments> <!-- 加载映射文件-->
<mappers>
<mapper resource="com/eggtwo/entity/MemberMapper.xml"/>
</mappers>
</configuration>
mybatis.cfg.xml加载的jdbc.properties文件
mysql.driver=com.mysql.jdbc.Driver
mysql.url=jdbc:mysql://127.0.0.1:3306/test
mysql.username=root
mysql.password=123456
4.定义mybatis帮助类:MybatisUtil
package com.eggtwo.dao; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import java.io.IOException;
import java.io.Reader;
import java.sql.Connection; public class MybatisUtil { private static ThreadLocal<SqlSession> threadLocal = new ThreadLocal<SqlSession>();
private static SqlSessionFactory sqlSessionFactory;
/**
* 加载位于src/mybatis.xml配置文件
*/
static{
try {
Reader reader = Resources.getResourceAsReader("mybatis.cfg.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
/**
* 禁止外界通过new方法创建
*/
private MybatisUtil(){}
/**
* 获取SqlSession
*/
public static SqlSession getSqlSession(){
//从当前线程中获取SqlSession对象
SqlSession sqlSession = threadLocal.get();
//如果SqlSession对象为空
if(sqlSession == null){
//在SqlSessionFactory非空的情况下,获取SqlSession对象
sqlSession = sqlSessionFactory.openSession();
//将SqlSession对象与当前线程绑定在一起
threadLocal.set(sqlSession);
}
//返回SqlSession对象
return sqlSession;
}
/**
* 关闭SqlSession与当前线程分开
*/
public static void closeSqlSession(){
//从当前线程中获取SqlSession对象
SqlSession sqlSession = threadLocal.get();
//如果SqlSession对象非空
if(sqlSession != null){
//关闭SqlSession对象
sqlSession.close();
//分开当前线程与SqlSession对象的关系,目的是让GC尽早回收
threadLocal.remove();
}
} }
5.定义MemberDao测试mybatis增删查改
6.测试
public static void main(String[] args) throws Exception {
Connection conn = MybatisUtil.getSqlSession().getConnection();
System.out.println(conn != null ? "连接成功" : "连接失败");
MemberDao memberDao = new MemberDao();
Member member = new Member();
member.setId(2);
member.setAge(14);
member.setName("张三1");
member.setBirthday(new Date());
member.setMan(true);
member.setScore(new BigDecimal(123.24));
memberDao.add(member);
// memberDao.update(member);
// memberDao.delete(3);
Member member1 = memberDao.getById(2);
System.out.println(member1.getName());
List<Member> memberList = memberDao.getPageList(2,2);
System.out.println("size:"+memberList.size());
for (Member m : memberList){
System.out.println(m.getId());
}
}
二、 动态SQL
1.多条件查询
mapper.xml配置
<select id="getListByWhere" parameterType="map" resultType="com.eggtwo.entity.Member">
select id,name,age,birthday,man,score
from t_member
<where>
<if test="name!=null and name!=''">
and name like #{name}
</if>
<if test="score!=null">
and score > #{score}
</if>
</where>
</select>
dao调用
public List<Member> getListByWhere(String name,BigDecimal score) throws Exception {
SqlSession sqlSession = null;
try {
sqlSession = MybatisUtil.getSqlSession();
Map<String,Object> map=new LinkedHashMap<>();
map.put("name",name==null?null: "%"+name+"%");//做like查询
map.put("score",score);
List<Member> memberList= sqlSession.selectList("memberDao.getListByWhere",map);
return memberList; } catch (Exception e) {
e.printStackTrace(); } finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
return null;
}
测试:
List<Member> memberList = memberDao.getListByWhere("3",new BigDecimal(30));
2.部分更新字段
mapper.xml配置
<update id="dynamicUpdate" parameterType="map">
update t_member
<set>
<if test="name!=null">
name = #{name},
</if>
<if test="age!=null">
age = #{age},
</if>
<if test="birthday!=null">
birthday = #{birthday},
</if>
<if test="man!=null">
man = #{man},
</if>
<if test="score!=null">
score = #{score},
</if>
</set>
where id=#{id}
</update>
dao调用:
public void dynamicUpdate(int id, String name,Integer age,Date birthday,Boolean man,BigDecimal score) throws Exception {
SqlSession sqlSession = null;
try {
sqlSession = MybatisUtil.getSqlSession();
Map<String,Object> map=new LinkedHashMap<>();
map.put("id",id);
map.put("name",name);
map.put("age",age);
map.put("birthday",birthday);
map.put("man",man);
map.put("score",score);
sqlSession.update("memberDao.dynamicUpdate", map);
//提交事务
sqlSession.commit(); } catch (Exception e) {
e.printStackTrace();
//事务回滚
sqlSession.rollback();
} finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
}
测试:
memberDao.dynamicUpdate(2,"jack",null,null,false,null);
3.根据id集合或数组不确定删除:delete from table where id in(id1,id2,id3,……)
mapper.xml配置
<!--根据ids数组批量删除数据-->
<delete id="batchDelete" >
delete from t_member where id in
<!--
循环数组
解析成:(1,2,34)
#id表示数组中的每一个元素,名称可以任意写
-->
<foreach collection="array" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
<!--根据ids列表批量删除数据-->
<delete id="batchDeleteList" >
delete from t_member where id in
<!--
循环数组
解析成:(1,2,34)
#id表示数组中的每一个元素,名称可以任意写
-->
<foreach collection="list" open="(" close=")" separator="," item="id">
#{id}
</foreach>
</delete>
dao调用:
public void batchDelete(int[] ids) throws Exception {
SqlSession sqlSession = null;
try {
sqlSession = MybatisUtil.getSqlSession();
sqlSession.update("memberDao.batchDelete", ids);
sqlSession.commit();
} catch (Exception e) {
e.printStackTrace();
//事务回滚
sqlSession.rollback();
} finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
}
public void batchDeleteList(List<Integer> ids) throws Exception {
SqlSession sqlSession = null;
try {
sqlSession = MybatisUtil.getSqlSession();
sqlSession.update("memberDao.batchDeleteList", ids);
sqlSession.commit();
} catch (Exception e) {
e.printStackTrace();
//事务回滚
sqlSession.rollback();
} finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
}
测试:
memberDao.batchDelete(new int[]{1,4,5});
List<Integer> list=new ArrayList<>() ;
list.add(1);
list.add(17);
list.add(18);
memberDao.batchDeleteList(list);
4.动态插入部分字段
这个不常用
三、 多表查询
1.一对一映射
班级包t_grade和学生表t_student表
获取学生信息时同时把学生对应的班级信息获取出来
第一步:创建实体
Grade实体
package com.eggtwo.entity; import java.util.List; public class Grade {
private Integer id;
private String gradeName; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getGradeName() {
return gradeName;
} public void setGradeName(String gradeName) {
this.gradeName = gradeName;
} }
Grade
Student实体
package com.eggtwo.entity; import java.util.Date; public class Student {
private Integer id;
private String name;
private Integer age;
private Date birthday;
private Boolean man;
private Grade grade; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Integer getAge() {
return age;
} public void setAge(Integer age) {
this.age = age;
} public Date getBirthday() {
return birthday;
} public void setBirthday(Date birthday) {
this.birthday = birthday;
} public Boolean getMan() {
return man;
} public void setMan(Boolean man) {
this.man = man;
} public Grade getGrade() {
return grade;
} public void setGrade(Grade grade) {
this.grade = grade;
}
}
com.eggtwo.entity.Student
第二步:建立mapper.xml
GradeMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="gradeDao">
<!--
*******当实体属性和表字段名称一致的话resultMap标签可以省略********
resultMap标签:映射实体和表关系
id:映射关系id,要唯一
type:实体全路径
-->
<resultMap id="gradeMap" type="com.eggtwo.entity.Grade">
<!--id:映射主键属性
result:映射非主键属性
property:实体属性名称
column:表字段名称
-->
<id property="id" column="id"/>
<result property="gradeName" column="gradeName"/>
</resultMap>
</mapper>
StudentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="studentDao">
<resultMap id="studentMap" type="com.eggtwo.entity.Student">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="age" column="age"/>
<result property="birthday" column="birthday"/>
<result property="man" column="man"/>
<!--引用GradeMapper.xml中的resultMap,不需要再写一遍映射-->
<association property="grade" resultMap="gradeDao.gradeMap"/>
</resultMap> <!--返回值类型用resultMap代替resultType,可以解决实体字段类型和表字段类型不一致的问题-->
<select id="getById" parameterType="int" resultMap="studentMap">
select s.id,s.name,s.age,s.birthday,s.man,g.id,g.gradeName
from t_student s, t_grade g
where s.gradeId=g.id
and s.id=#{id}
</select> </mapper>
第三步:将mapper.xml加入到mybatis.cfg.xml文件中
<mappers>
<mapper resource="com/eggtwo/entity/StudentMapper.xml"/>
<mapper resource="com/eggtwo/entity/GradeMapper.xml"/>
</mappers>
第四步:编写StudentDao
package com.eggtwo.dao; import com.eggtwo.entity.Member;
import com.eggtwo.entity.Student;
import org.apache.ibatis.session.SqlSession; import java.math.BigDecimal;
import java.sql.Connection;
import java.util.*; public class StudentDao {
public Student getById(int id) throws Exception {
SqlSession sqlSession = null;
Student student = null;
try {
sqlSession = MybatisUtil.getSqlSession();
student = sqlSession.selectOne("studentDao.getById", id); } catch (Exception e) {
e.printStackTrace(); } finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
return student;
} }
第五步:测试
public static void main(String[] args) throws Exception { StudentDao studentDao = new StudentDao();
Student s = studentDao.getById(2);
System.out.println(s.getName());
}
2.一对多映射
根据班级名称获取学生列表信息
第一步:创建实体
Grade实体
package com.eggtwo.entity; import java.util.ArrayList;
import java.util.List; public class Grade {
private Integer id;
private String gradeName;
private List<Student> studentList = new ArrayList<Student>(); public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getGradeName() {
return gradeName;
} public void setGradeName(String gradeName) {
this.gradeName = gradeName;
} public List<Student> getStudentList() {
return studentList;
} public void setStudentList(List<Student> studentList) {
this.studentList = studentList;
}
}
Student实体
package com.eggtwo.entity; import java.util.Date; public class Student {
private Integer id;
private String name;
private Integer age;
private Date birthday;
private Boolean man;
private Grade grade; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Integer getAge() {
return age;
} public void setAge(Integer age) {
this.age = age;
} public Date getBirthday() {
return birthday;
} public void setBirthday(Date birthday) {
this.birthday = birthday;
} public Boolean getMan() {
return man;
} public void setMan(Boolean man) {
this.man = man;
} public Grade getGrade() {
return grade;
} public void setGrade(Grade grade) {
this.grade = grade;
}
}
第二步:建立mapper.xml
GradeMapper.xml和StudentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="gradeDao">
<!--
*******当实体属性和表字段名称一致的话resultMap标签可以省略********
resultMap标签:映射实体和表关系
id:映射关系id,要唯一
type:实体全路径
-->
<resultMap id="gradeMap" type="com.eggtwo.entity.Grade">
<!--id:映射主键属性
result:映射非主键属性
property:实体属性名称
column:表字段名称
-->
<id property="id" column="id"/>
<result property="gradeName" column="gradeName"/>
</resultMap>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="studentDao">
<resultMap id="studentMap" type="com.eggtwo.entity.Student">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="age" column="age"/>
<result property="birthday" column="birthday"/>
<result property="man" column="man"/>
</resultMap> <select id="getListByGradeName" parameterType="string" resultMap="studentMap">
select s.id,s.name,s.age,s.birthday,s.man
from t_student s, t_grade g
where s.gradeId=g.id
and g.gradeName=#{gradeName}
</select>
</mapper>
第三步:将mapper.xml加入到mybatis.cfg.xml文件中
省略
第四步:编写StudentDao
public List<Student> getListByGradeName(String gradeName) throws Exception {
SqlSession sqlSession = null;
List<Student> studentList = null;
try {
sqlSession = MybatisUtil.getSqlSession();
studentList = sqlSession.selectList("studentDao.getListByGradeName",gradeName); } catch (Exception e) {
e.printStackTrace(); } finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
return studentList;
}
第五步:测试
List<Student> studentList = studentDao.getListByGradeName("一班");
3.自定义实体对象(不和数据库表对应)用于接收多表查询出来的复合数据
第一步:定义实体GradeStudent
package com.eggtwo.entity; import java.util.Date; public class GradeStudent {
private Integer gradeId;
private String gradeName; private Integer studentId;
private String studentName;
private Integer studentAge;
private Date studentBirthday; public Integer getGradeId() {
return gradeId;
} public void setGradeId(Integer gradeId) {
this.gradeId = gradeId;
} public String getGradeName() {
return gradeName;
} public void setGradeName(String gradeName) {
this.gradeName = gradeName;
} public Integer getStudentId() {
return studentId;
} public void setStudentId(Integer studentId) {
this.studentId = studentId;
} public String getStudentName() {
return studentName;
} public void setStudentName(String studentName) {
this.studentName = studentName;
} public Integer getStudentAge() {
return studentAge;
} public void setStudentAge(Integer studentAge) {
this.studentAge = studentAge;
} public Date getStudentBirthday() {
return studentBirthday;
} public void setStudentBirthday(Date studentBirthday) {
this.studentBirthday = studentBirthday;
} public Boolean getStudentMan() {
return studentMan;
} public void setStudentMan(Boolean studentMan) {
this.studentMan = studentMan;
} private Boolean studentMan;
}
第二步:定义GradeStudentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--映射文件命名空间:要唯一-->
<mapper namespace="gradeStudentDao">
<resultMap id="gradeStudentMap" type="com.eggtwo.entity.GradeStudent"> <result property="studentId" column="studentId"/>
<result property="studentName" column="studentName"/>
<result property="studentAge" column="studentAge"/>
<result property="studentBirthday" column="studentBirthday"/>
<result property="studentMan" column="studentMan"/>
<result property="gradeId" column="gradeId"/>
<result property="gradeName" column="gradeName"/>
</resultMap> <!--返回值类型用resultMap代替resultType,可以解决实体字段类型和表字段类型不一致的问题-->
<select id="getGradeStudentList" resultMap="gradeStudentMap">
select s.id as studentId,
s.name as studentName,
s.age as studentAge,
s.birthday as studentBirthday,
s.man as studentMan,
g.id as gradeId,
g.gradeName
from t_student s, t_grade g
where s.gradeId=g.id
</select> </mapper>
第三步:将GradeStudentMapper.xml加入mybatis.xml
<mappers>
<mapper resource="com/eggtwo/entity/MemberMapper.xml"/>
<mapper resource="com/eggtwo/entity/StudentMapper.xml"/>
<mapper resource="com/eggtwo/entity/GradeMapper.xml"/>
<mapper resource="com/eggtwo/entity/GradeStudentMapper.xml"/>
</mappers>
第四步:编写dao
public List<GradeStudent> getGradeStudentList() throws Exception {
SqlSession sqlSession = null;
List<GradeStudent> gradeStudentList = null;
try {
sqlSession = MybatisUtil.getSqlSession();
gradeStudentList = sqlSession.selectList("gradeStudentDao.getGradeStudentList"); } catch (Exception e) {
e.printStackTrace(); } finally {
//关闭连接
MybatisUtil.closeSqlSession();
}
return gradeStudentList;
}
java web开发入门七(mybatis)基于intellig idea的更多相关文章
- day04 Java Web 开发入门
day04 Java Web 开发入门 1. web 开发相关介绍 2. web 服务器 3. Tomcat服务器启动的问题 4. Tomcat目录结构 5. Web应用程序(虚拟目录映射,缺省web ...
- java WEB开发入门
WEB开发入门 1 进入web JAVASE:标准- standard JAVA桌面程序 GUI SOCKET JAVAEE:企业-浏览器控制 web 2 软件结构 C/S :client ...
- java web 开发入门实例
学习是个技巧活,关键是要找到重点的地方,新手在这方面的坑尤其多.看别人的教程一步一步的跟着做,隔几步就遇到一个新知识点,忍不住就百度往深处了解,一晃半天就过去了. 有的知识点要深入学习的,有的是了解下 ...
- java web 开发入门 --- tomcat/servlet/jsp
在做java web 开发时,要先安装tomcat.它是一个web服务器,也叫web容器,我们把写好的jsp, html页面放到它里面,然后启动它,就可以用浏览器访问这些页面,地址栏中输入localh ...
- java web 开发入门
Java web,是java技术用来解决web互联网领域的技术总和.Java web技术主要包括客户端和服务端,java在客户端的服务有java applet,不过用的非常少,大部分应用在服务端,比如 ...
- java web开发入门一(servlet和jsp)基于eclispe
servlet 用java语言开发动态资源网站的技术,在doGet方法中拼接显示html,在doPost方法中提交数据.类似于.net的ashx技术. servlet生成的class文件存放在tomc ...
- java web开发入门汇总
servlet 用java语言开发动态资源网站的技术,在doGet方法中拼接显示html,在doPost方法中提交数据.类似于.net的ashx技术. servlet生成的class文件存放在tomc ...
- Java开发工程师(Web方向) - 01.Java Web开发入门 - 第3章.Tomcat
第3章--Tomcat Tomcat安装与运行 Tomcat:目前最常用的基于java的web应用服务器 本课程中所有的Java代码最终都需要部署到Tomcat中运行 Tomcat的配置文件是XML的 ...
- Java开发工程师(Web方向) - 01.Java Web开发入门 - 第6章.蜂巢
第6章--蜂巢 蜂巢简介 网站开发完,就需要测试.部署.在服务器上运行. 网易蜂巢: 采用Docker容器化技术的云计算平台 https://c.163.com 容器管理:容器可被视作为云主机的服务器 ...
随机推荐
- React及Nextjs相关知识点小结
React及Nextjs知识点小结 函数式组件和类组件区别是什么 1.函数式组件是用于创建无状态的组件,组件不会被实例化,无法访问this中的对象,无法访问生命周期方法,是无副作用的,相比于类组件函数 ...
- Spring Cloud Ribbon客户端负载均衡(四)
序言 Ribbon 是一个客户端负载均衡器(Nginx 为服务端负载均衡),它赋予了应用一些支配 HTTP 与 TCP 行为的能力,可以得知,这里的客户端负载均衡也是进程内负载均衡的一种.它在 Spr ...
- Window权限维持(九):端口监视器
后台打印程序服务负责管理Windows操作系统中的打印作业.与服务的交互通过打印后台处理程序API执行,该API包含一个函数(AddMonitor),可用于安装本地端口监视器并连接配置.数据和监视器文 ...
- WPF-数据模板深入(加载XML类型数据)
一.我们知道WPF数据模板是当我们给定一个数据类型,我们为这个数据类型写好布局,就给这种数据类型穿上了外衣. 下面这个例子,能够帮助大家充分理解数据模板就是数据类型的外衣的意思:(里面的MyListB ...
- c# 模拟表单提交,post form 上传文件、数据内容
转自:https://www.cnblogs.com/DoNetCShap/p/10696277.html 表单提交协议规定:要先将 HTTP 要求的 Content-Type 设为 multipar ...
- php中函数 isset(), empty(), is_null() 的区别,boolean类型和string类型的false判断
php中函数 isset(), empty(), is_null() 的区别,boolean类型和string类型的false判断 实际需求:把sphinx返回的结果放到ssdb缓存里,要考虑到sph ...
- Linux中用postfix搭建邮件服务器实战详解
Linux中用postfix搭建邮件服务器实战详解 postfix是Wietse Venema在IBM的GPL协议之下开发的MTA(邮件传输代理)软件.Postfix试图更快.更容易管理.更安全,同时 ...
- PMP备考-第二章-项目运行环境与项目经理
组织系统的三大因素:组织治理框架,管理要素和组织结构 组织治理和项目治理 组织治理 :组织中的重要决策制定框架,谁有权在什么时候用什么发放做出并推行什么重要决策. 项目治理 :组织为项目建立的高级别的 ...
- Struts2 运行流程
Struts2运行流程 1.在web.xml中使用Struts的核心过滤器拦截所有请求. <filter> <filter-name>struts2</filter-na ...
- Google Analytics 学习笔记一 —— GA简介
GA的原理 网页页面添加GA跟踪代码,以"一像素"传递信息给服务器 hit(交互) --> sessions(会话) --> user(用户) 竞品对比 Firebas ...