回忆了 Spring、SpringMVC、MyBatis 框架整合,完善一个小demo,包括基本的增删改查功能。

开发环境

  • IDEA
  • MySQL 5.7
  • Tomcat 9
  • Maven 3.2.5
  • 需要熟练掌握MySQL数据库(建表和增删改查语句等,Spring,JavaWeb基础及MyBatis知识,简单的前端知识;

数据库环境

CREATE DATABASE `ssmbuild`;

USE `ssmbuild`;

CREATE TABLE `books` (
`bookID` INT(10) NOT NULL AUTO_INCREMENT COMMENT '书id',
`bookName` VARCHAR(100) NOT NULL COMMENT '书名',
`bookCounts` INT(11) NOT NULL COMMENT '数量',
`detail` VARCHAR(200) NOT NULL COMMENT '描述',
KEY `bookID` (`bookID`)
) ENGINE=INNODB DEFAULT CHARSET=utf8 INSERT INTO `books`(`bookID`,`bookName`,`bookCounts`,`detail`)VALUES
(1,'Java',1,'从入门到放弃'),
(2,'MySQL',10,'从删库到跑路'),
(3,'Linux',5,'从进门到进牢');

开发项目首先搭建基本的环境

  1. 新建一Maven项目!SSM , 添加web的支持
  2. 导入相关的pom依赖!
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>jiachuixun</groupId>
<artifactId>SSM</artifactId>
<version>1.0-SNAPSHOT</version> <dependencies>
<!--Junit-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!--数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<!-- 数据库连接池 -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>
<!--Servlet - JSP -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!--Mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.2</version>
</dependency>
<!--Spring-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
<!-- lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>provided</scope>
</dependency>
<!--AOP 织入器-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies> </project>

  3.Maven资源过滤配置

<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>

建议基本结构和配置框架

  • com.jia.controller    (控制层)
  • com.jia.mapper     (持久层)
  • com.jia.service      (业务层)
  • com.jia.pojo           (实体类)

  • mybatis-config
<?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> </configuration>
  • applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> </beans>

Mybatis层编写配置

1. 数据库配置文件 database.properties

jdbc.driver=com.mysql.cj.jdbc.Driver
# 如果使用的是MySQL8.0+ ,增加一个时区的配置
jdbc.url=jdbc:mysql://localhost:3306/books?useSSL=true&useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
jdbc.username=root
jdbc.password=123456

2. 编写Mybatis核心配置文件

<?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>
<typeAliases>
<package name="com.jia.pojo"/>
</typeAliases>
<mappers>
<package name="com.jia.mapper"/>
</mappers>
</configuration>

  3. 编写数据库对应的实体类com.jia.pojo.Books  (使用lombok插件)

package com.jia.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; @Data
@AllArgsConstructor
@NoArgsConstructor
public class Books {
private int bookId;
private String bookName;
private int bookCounts;
private String detail;
}

4. 编写mapper层的接口:BooksMapper

package com.jia.mapper;

import com.jia.pojo.Books;
import org.apache.ibatis.annotations.Param; import java.util.List; public interface BooksMapper { //添加数据
int addBooks(Books books); //删除数据
int deleteBookById(@Param("bookId") int id); //更新数据
int updateBook(Books books); //查询一条数据
Books queryBookById(@Param("bookId") int id); //查询全部数据
List<Books> queryAllBook(); //查询指定的书籍
Books queryBooksByName(@Param("bookName") String bookName); }

5. 编写接口对应的Mapper.xml文件:BooksMapper.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="com.jia.mapper.BooksMapper"> <insert id="addBooks" parameterType="Books">
insert into Books (bookName, bookCounts, detail)
values (#{bookName},#{bookCounts},#{detail});
</insert> <delete id="deleteBookById" parameterType="int">
delete from Books where bookId = #{bookId};
</delete> <update id="updateBook" parameterType="Books">
update Books
set bookName=#{bookName},bookCounts=#{bookCounts},detail=#{detail}
where bookId=#{bookId};
</update> <select id="queryBookById" resultType="Books" parameterType="int">
select * from Books where bookId=#{bookId};
</select> <select id="queryAllBook" resultType="Books">
select * from Books;
</select> <select id="queryBooksByName" resultType="Books" parameterType="String">
select * from books where bookName=#{bookName}
</select> </mapper>

6. 变写service层接口和实现类

BooksService接口:

package com.jia.service;

import com.jia.pojo.Books;

import java.util.List;

public interface BooksService {

    //添加数据
int addBooks(Books books); //删除数据
int deleteBookById(int id); //更新数据
int updateBook(Books books); //查询一条数据
Books queryBookById(int id); //查询全部数据
List<Books> queryAllBook(); //查询指定的书籍
Books queryBooksByName(String bookName); }

BookServiceImpl实现类:

package com.jia.service.impl;

import com.jia.mapper.BooksMapper;
import com.jia.pojo.Books;
import com.jia.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired; import java.util.List; public class BooksServiceImpl implements BooksService { // 业务层 调用 持久层
@Autowired
private BooksMapper booksMapper; // 添加set方法,方便Spring注入IOC容器中
public void setBooksMapper(BooksMapper booksMapper) {
this.booksMapper = booksMapper;
} public int addBooks(Books books) {
return booksMapper.addBooks(books);
} public int deleteBookById(int id) {
return booksMapper.deleteBookById(id);
} public int updateBook(Books books) {
return booksMapper.updateBook(books);
} public Books queryBookById(int id) {
return booksMapper.queryBookById(id);
} public List<Books> queryAllBook() {
return booksMapper.queryAllBook();
} public Books queryBooksByName(String bookName) {
return booksMapper.queryBooksByName(bookName);
} }

Spring的配置

1. 配置Spring整合MyBatis,这里数据源使用c3p0连接池

2. 编写Spring整合MyBatis相关的配置,spring-dao.xml

<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd"> <!--1.关联数据库配置文件-->
<context:property-placeholder location="classpath:database.properties"/> <!--2.数据库连接池:
dbcp 半自动化操作 不能自动连接
c3p0 自动化操作(自动的加载配置文件 并且设置到对象里面)
druid 阿里巴巴出品
hikari SpringBoot默认
-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- c3p0连接池的私有属性 -->
<property name="maxPoolSize" value="30"/>
<property name="minPoolSize" value="10"/>
<!-- 关闭连接后不自动commit -->
<property name="autoCommitOnClose" value="false"/>
<!-- 获取连接超时时间 -->
<property name="checkoutTimeout" value="10000"/>
<!-- 当获取连接失败重试次数 -->
<property name="acquireRetryAttempts" value="2"/>
</bean> <!--3.配置SqlSessionFactory对象-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置MyBaties全局配置文件:mybatis-config.xml -->
<property name="configLocation" value="classpath:mybatis-config.xml"/>
</bean> <!-- 4.配置扫描mapper接口包,动态实现mapper接口注入到Spring容器中 -->
<bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<!-- 给出需要扫描Dao接口包 -->
<property name="basePackage" value="com.jia.mapper"/>
</bean> </beans>

3. Spring配置service层

<?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
https://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="booksService" class="com.jia.service.impl.BooksServiceImpl">
<property name="booksMapper" ref="booksMapper"/>
</bean> <!-- 扫描service相关的bean -->
<context:component-scan base-package="com.jia.service"/> <!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 注入数据库连接池 -->
<property name="dataSource" ref="dataSource" />
</bean> <!--aop 事务支持-->
<tx:advice id="txAdice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--配置事务切入-->
<aop:config>
<!--切入点-->
<aop:pointcut id="txPointCut" expression="execution(* com.jia.mapper.*.*(..))"/>
<aop:advisor advice-ref="txAdice" pointcut-ref="txPointCut"/>
</aop:config> </beans>

SpringMVC层配置

1. 首先项目添加框架支持Web,修改WEB-INF文件下web.xml文件内容

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"> <!--DispatcherServlet-->
<servlet>
<servlet-name>DispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>DispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> <!--encodingFilter-->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!--Session过期时间-->
<session-config>
<session-timeout>15</session-timeout>
</session-config> </web-app>

2. 配置编写 spring-mvc.xml 文件

<?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:mvc="http://www.springframework.org/schema/mvc"
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/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 配置SpringMVC -->
<!-- 1.开启SpringMVC注解驱动 -->
<mvc:annotation-driven /> <!-- 2.过滤静态资源-->
<mvc:default-servlet-handler/> <!-- 3.配置jsp 显示ViewResolver视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="resourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> <!-- 4.扫描web相关的bean -->
<context:component-scan base-package="com.jia.controller" /> <!-- 5.json乱码问题-->
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven> <!-- 6.文件上传-->
<!-- 定义文件解释器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 设置默认编码 -->
<property name="defaultEncoding" value="utf-8"/>
<!-- 上传图片最大大小5M-->
<property name="maxUploadSize" value="10485760"/>
<property name="maxInMemorySize" value="40960"/>
</bean>

</beans>

3. Spring配置整合文件:applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> <import resource="classpath:spring-dao.xml"/>
<import resource="classpath:spring-service.xml"/>
<import resource="classpath:spring-mvc.xml"/> </beans>

以上架构基本配置完成!剩下的就是编写需求实现具体的功能!

Controller 和 View

1. BookController 类编写

package com.jia.controller;

import com.jia.pojo.Books;
import com.jia.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.ArrayList;
import java.util.List; @Controller
@RequestMapping("/book")
public class BooksController { // controller层 调用 service层
@Autowired
@Qualifier("booksService")
private BooksService booksService; // 查询全部的数据,并且返回到一个数据展示页面
@RequestMapping("/allBook")
public String list(Model model){
List<Books> books = booksService.queryAllBook();
model.addAttribute("list",books);
return "allBook";
} // 跳转到添加书籍页面
@RequestMapping("/toAddPaper")
public String toAddPaper(){
return "addBook";
} // 添加书籍请求
@RequestMapping("/addBook")
public String addBook(Books books){
System.out.println("addBook-->"+books);
booksService.addBooks(books);
return "redirect:/book/allBook";
} // 跳转到修改页面
@RequestMapping("/toUpdate")
public String toUpdatePaper(int id,Model model){
Books books = booksService.queryBookById(id);
model.addAttribute("Qbook",books);
return "updateBook";
} // 修改书籍
@RequestMapping("/updateBook")
public String updateBook(Books books){
System.out.println("updateBook-->"+books);
booksService.updateBook(books);
return "redirect:/book/allBook";
} // 删除书籍
@RequestMapping("/deleteBook/{bookId}")
public String deleteBook(@PathVariable("bookId") int id){
booksService.deleteBookById(id);
return "redirect:/book/allBook";
} // 查询书籍
@RequestMapping("/queryBook")
public String queryBook(String bookName,Model model){
Books books = booksService.queryBooksByName(bookName); List<Books> list = new ArrayList<Books>();
list.add(books); if (books == null){
list = booksService.queryAllBook();
model.addAttribute("error","未查到相关内容");
} model.addAttribute( "list", list);
return "allBook";
}
}

2. 编写首页 index.jsp   (页面有点简陋,基本的功能都有CRUD)

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
<style>
a {
text-decoration: none;
color: black;
font-size: 18px;
}
h3 {
width: 180px;
height: 38px;
margin: 100px auto;
text-align: center;
line-height: 38px;
background: deepskyblue;
border-radius: 4px;
}
</style>
</head>
<body>
<h3>
<a href="${pageContext.request.contextPath}/book/allBook">登录</a>
</h3>
</body>
</html>

2. 数据展示页面 allBook.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>书籍列表</title>
<!-- 引入 Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body> <div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
<small>书籍列表 —— 显示所有书籍</small>
</h1>
</div>
</div> <div class="row">
<div class="col-md-4 column">
<a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddPaper">添加书籍</a>
<a class="btn btn-primary" href="${pageContext.request.contextPath}/book/allBook">显示全部书籍</a>
</div>
<div class="col-md-4 column"></div>
<div class="col-md-4 column">
<%--查询书籍--%>
<form class="form-inline" action="${pageContext.request.contextPath}/book/queryBook" method="post" style="float: right">
<span style="color:red;font-weight: bold">${error}</span>
<input type="text" name="bookName" class="form-control" placeholder="查询书籍的名称">
<input type="submit" class="btn btn-primary" value="查询">
</form>
</div>
</div>
</div> <div class="row clearfix">
<div class="col-md-12 column">
<table class="table table-hover table-striped">
<thead>
<tr>
<th>书籍编号</th>
<th>书籍名字</th>
<th>书籍数量</th>
<th>书籍详情</th>
<th>操作</th>
</tr>
</thead> <tbody>
<c:forEach var="book" items="${list}">
<tr>
<td>${book.bookId}</td>
<td>${book.bookName}</td>
<td>${book.bookCounts}</td>
<td>${book.detail}</td>
<td>
<a href="${pageContext.request.contextPath}/book/toUpdate?id=${book.bookId}">修改</a>
&nbsp; | &nbsp;
<a href="${pageContext.request.contextPath}/book/deleteBook/${book.bookId}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div> </div>

3. 添加书籍页面 addBook.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>添加书籍</title>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
<small>添加数据</small>
</h1>
</div>
</div>
</div> <form action="${pageContext.request.contextPath}/book/addBook" method="post">
<div class="form-group">
<label>书籍名称</label>
<input type="text" class="form-control" name="bookName" placeholder="输入书籍名称" required>
</div>
<div class="form-group">
<label>书籍数量</label>
<input type="text" class="form-control" name="bookCounts" placeholder="输入书籍数量" required>
</div>
<div class="form-group">
<label>书籍详情</label>
<input type="text" class="form-control" name="detail" placeholder="输入书籍详情" required>
</div>
<button type="submit" class="btn btn-primary">添加</button>
</form> </div>
</body>
</html>

4. 修改书籍页面 updateBook.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>修改书籍</title>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
<small>修改数据</small>
</h1>
</div>
</div>
</div> <form action="${pageContext.request.contextPath}/book/updateBook" method="post">
<%--前端传递隐藏域--%>
<input type="hidden" name="bookId" value="${Qbook.bookId}"/>
<div class="form-group">
<label>书籍名称</label>
<input type="text" class="form-control" name="bookName" value="${Qbook.bookName}" placeholder="输入书籍名称" required>
</div>
<div class="form-group">
<label>书籍数量</label>
<input type="text" class="form-control" name="bookCounts" value="${Qbook.bookCounts}" placeholder="输入书籍数量" required>
</div>
<div class="form-group">
<label>书籍详情</label>
<input type="text" class="form-control" name="detail" value="${Qbook.detail}" placeholder="输入书籍详情" required>
</div>
<button type="submit" class="btn btn-primary">修改</button>
</form> </div>
</body>
</html>

最后在IDEA里点击Tomcat服务器发布项目  OK完成!

SSM(Spring+SpringMVC+MyBatis)框架整合开发流程的更多相关文章

  1. SSM(Spring,SpringMVC,Mybatis)框架整合项目

    快速上手SSM(Spring,SpringMVC,Mybatis)框架整合项目 环境要求: IDEA MySQL 8.0.25 Tomcat 9 Maven 3.6 数据库环境: 创建一个存放书籍数据 ...

  2. SSM Spring SpringMVC Mybatis框架整合Java配置完整版

    以前用着SSH都是老师给配好的,自己直接改就可以.但是公司主流还是SSM,就自己研究了一下Java版本的配置.网上大多是基于xnl的配置,但是越往后越新的项目都开始基于JavaConfig配置了,这也 ...

  3. SSM(Spring+SpringMVC+Mybatis)框架环境搭建(整合步骤)(一)

    1. 前言 最近在写毕设过程中,重新梳理了一遍SSM框架,特此记录一下. 附上源码:https://gitee.com/niceyoo/jeenotes-ssm 2. 概述 在写代码之前我们先了解一下 ...

  4. SSM(Spring +SpringMVC + Mybatis)框架搭建

    SSM(Spring +SpringMVC + Mybatis)框架的搭建 最近通过学习别人博客发表的SSM搭建Demo,尝试去搭建一个简单的SSMDemo---实现的功能是对用户增删改查的操作 参考 ...

  5. SSM(Spring + Springmvc + Mybatis)框架面试题

    JAVA SSM框架基础面试题https://blog.csdn.net/qq_39031310/article/details/83050192 SSM(Spring + Springmvc + M ...

  6. SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释(转)

    原文:https://blog.csdn.net/yijiemamin/article/details/51156189# 这几天一直在整合SSM框架,虽然网上有很多已经整合好的,但是对于里面的配置文 ...

  7. 0927-转载:SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释

    这篇文章暂时只对框架中所要用到的配置文件进行解释说明,而且是针对注解形式的,框架运转的具体流程过两天再进行总结. spring+springmvc+mybatis框架中用到了三个XML配置文件:web ...

  8. SSM:spring+springmvc+mybatis框架中的XML配置文件功能详细解释

    这几天一直在整合SSM框架,虽然网上有很多已经整合好的,但是对于里面的配置文件并没有进行过多的说明,很多人知其然不知其所以然,经过几天的搜索和整理,今天总算对其中的XML配置文件有了一定的了解,所以拿 ...

  9. [置顶] Java Web学习总结(24)——SSM(Spring+SpringMVC+MyBatis)框架快速整合入门教程

    1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One  ...

随机推荐

  1. Java 线程的 5 种状态

    线程状态图: 线程共包括以下 5 种状态: 1. 新建状态(New): 线程对象被创建后,就进入了新建状态.例如,Thread thread = new Thread(). 2. 就绪状态(Runna ...

  2. NFS共享Nginx网页根目录(自动部署)

    IP HOSTNAME SERVICE SYSTEM 192.168.131.132 proxy-nfs nginx+nfs-server CentOS 7.6 192.168.131.131 ngi ...

  3. Eureka Server启动过程

    前面对Eureka的服务端及客户端的使用均已成功实践,对比Zookeeper注册中心的使用区别还是蛮大的: P:分区容错性(⼀定的要满⾜的)C:数据⼀致性 A:⾼可⽤:CAP不可能同时满⾜三个,要么是 ...

  4. CentOS8上安装MySQL

    没有选择Win10上安装MySQL,个人感觉比较傻瓜式.同时相对Win10操作系统,个人更熟悉Unix/Linux操作系统,所以选择在CentOS8上安装MySQL数据库. 还是熟悉的yum安装,前提 ...

  5. Vue 源码解读(4)—— 异步更新

    前言 上一篇的 Vue 源码解读(3)-- 响应式原理 说到通过 Object.defineProperty 为对象的每个 key 设置 getter.setter,从而拦截对数据的访问和设置. 当对 ...

  6. requests post/get请求params参数和post请求正文的数据类型记录

    1. 前言 在写接口数据驱动测试框架时,(从excel表中读取的非数据的值都是str类型),发送post/get请求因为数据类型原因,请求失败,走了一些弯路,记录总结一下请求的参数或者请求正文的数据类 ...

  7. Centos7 增加swap分区的内存大小

    Centos7 增加swap分区的内存大小 对 swap 空间的适当大小实际上取决于您的个人偏好和您的应用程序要求.通常,等于或双倍于系统内存的量是一个很好的选择 添加swap分区使用dd命令创建/h ...

  8. 大数据分析用自助式BI工具就能轻松解决,so easy!

    之前老板给了我一个任务,让我赶紧学习一下大数据分析,下个季度就要用. 赶紧看了一下日历,这离下个季度还有不到半个月的时间,而且我还没有数据分析基础,该怎么能在这么短的时间内学会大数据分析呢-- 经过多 ...

  9. 都在用神器,只有你还在死磕excel做分析

    一.excel数据分析工具_EXCE弱点 EXCEL一直是非常流行的个人计算机数据处理工具,它可以处理多种多样的数据,操作非常简单,支持丰富的函数.统计图表,在工作中更是非常得力的生产力工具.然而随着 ...

  10. MySQL-常用的几种修改密码方法

    在MySQL中一般常规的给用户修改密码可以用到以下几种方法: 1.使用 mysqladmin命令修改密码 1 mysqladmin -u username -p password "newP ...