完整SSM框架图书管理系统开发流程
环境:
IDEA
MySQL 5.5.62
Tomcat 8.5.61
Maven 3.6
1.数据库环境
创建一个存放书籍数据的数据库表
CREATE DATABASE `ssmbuild`;
USE `ssmbuild`;
DROP TABLE IF EXISTS `books`;
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,'从进门到进牢');
2.基本环境搭建
- 新建一Maven项目!ssmbuild , 添加web的支持
- 导入相关的pom依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.12</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.78</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.12</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
<!-- https://mvnrepository.com/artifact/taglibs/standard -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl -->
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
3.maven资源解析
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
4.基本结构和配置框架
5.配置mybatis-config.xml(只需配置设置和别名即可,其他使用spring的数据源替换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> <!--核心配置文件--> <!--在xml中所有标签都要规定其顺序-->
<!--1引入web配置文件-->
<!--2设置-->
<!--开启驼峰命名映射是否开启驼峰命名自动映射,即从经典数据库列名 A_COLUMN 映射到经典 Java 属性名 aColumn。 -->
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
<setting name="logImpl" value="STDOUT_LOGGING"/>
<!--显示开启全局缓存-->
<setting name="cacheEnabled" value="true"/>
</settings>
<typeAliases>
<typeAlias type="com.ji.pojo.Books"/>
</typeAliases>
<!--每一个Mapper.xml都需要在mybatis核心配置文件中注册-->
<!--使用注解时不需要绑定配置文件,需要绑定接口-->
<mappers>
<package name="com.ji.dao"/>
</mappers>
</configuration>
5.编写pojo层
实体类
package com.ji.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;
}
6.编写dao层(操作数据库)
Mapper接口
package com.ji.dao;
import com.ji.pojo.Books;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BooksMapper {
//增加
int addBook(Books books);
//删除
int deleteBooks(@Param ("bookID") int id);
//更改
int updateBooks(Books books);
//查询一本书
Books queryBooks(@Param ("bookID") int id);
List<Books> queryAllBooks();
List<Books> queryBookByName(String bookName);
}
mapper.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.ji.dao.BooksMapper">
<insert id="addBook" parameterType="Books">
insert into `books`(`bookName`,`bookCounts`,`detail`)
values (#{bookName},#{bookCounts},#{detail})
</insert>
<delete id="deleteBooks" parameterType="int">
delete from `books`
<where>
`bookID`=#{bookID}
</where>
</delete>
<update id="updateBooks" parameterType="Books">
update `books`
<set>
`bookName`=#{bookName},`bookCounts`=#{bookCounts},`detail`=#{detail}
</set>
<where>
`bookID`=#{bookID}
</where>
</update>
<select id="queryBooks" parameterType="int" resultType="Books">
select * from `books`
<where>
`bookID`=#{bookID}
</where>
</select>
<select id="queryBookByName" parameterType="String" resultType="Books">
select * from `books`
<where>
`bookName`=#{bookName}
</where>
</select>
<select id="queryAllBooks" resultType="Books">
select * from `books`
</select>
</mapper>
使用spring-dao.xml代替mybatis-config.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:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--关联数据库配置文件-->
<context:property-placeholder location="classpath:db.properties"/>
<!--连接池-->
<bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&characterEncoding=UTF-8"/>
<property name="user" value="root"/>
<property name="password" value="root"/>
</bean>
<!--sqlSessionFactory-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
</bean>
<!--配置dao接口扫描包,动态实现了dao接口可以注入到spring容器中 无需继承实现类和私有化构造sqlSessionTemplate-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--注入sqlSessionFactory-->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
<!--扫描要扫描的包-->
<property name="basePackage" value="com.ji.dao"/>
</bean>
<!--sqlSessionTemplate 继承实现类-->
</beans>
7.编写service层
spring-service.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:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://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
https://www.springframework.org/schema/mvc/tx.xsd">
<!--1.扫描service下的包-->
<context:component-scan base-package="com.ji.service"/>
<import resource="spring-dao.xml"/>
<!--2.将我们的所有业务类注入到spring 可以通过配置-->
<bean id="BookServiceImpl" class="com.ji.service.BookServiceImpl">
<property name="booksMapper" ref="booksMapper"/>
</bean>
<!--3.声明式事务-->
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
<!--注入数据源-->
<property name="dataSource" ref="datasource"/>
</bean>
<!--4.aop横切事务支持-->
<!--<tx:advice id="txAdvice" transaction-manager="transactionManager">
//给哪些方法配置事务
//配置事务的传播特性
<tx:attributes>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
//配置事务切入
<aop:config>
<aop:pointcut id="pointCut" expression="execution(* com.ji.dao.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointCut"/>
</aop:config>-->
</beans>
Bookservice层接口
package com.ji.service;
import com.ji.pojo.Books;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BookService {
//增加
int addBook(Books books);
//删除
int deleteBooks(int id);
//更改
int updateBooks(Books books);
//查询一本书
Books queryBooks(int id);
List<Books> queryAllBooks();
List<Books> queryBookByName(String bookName);
}
BookService实现类
package com.ji.service;
import com.ji.dao.BooksMapper;
import com.ji.pojo.Books;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
public class BookServiceImpl implements BookService{
//service层调用dao层,组合dao
private BooksMapper booksMapper;
public BooksMapper getBooksMapper() {
return booksMapper;
}
public void setBooksMapper(BooksMapper booksMapper) {
this.booksMapper = booksMapper;
}
public int addBook(Books books) {
return booksMapper.addBook (books);
}
public int deleteBooks(int id) {
return booksMapper.deleteBooks (id);
}
public int updateBooks(Books books) {
return booksMapper.updateBooks (books);
}
public Books queryBooks(int id) {
return booksMapper.queryBooks (id);
}
public List<Books> queryAllBooks() {
return booksMapper.queryAllBooks ();
}
public List<Books> queryBookByName(String bookName) {
return booksMapper.queryBookByName (bookName);
}
}
8.配置(springmvc)
配置springmvc-servlet.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:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--自动扫描包,让指定包下的注解生效,由ioc容器统一管理-->
<context:component-scan base-package="com.ji.controller"/>
<!--让springMVC不处理静态资源 .css .js .html .mp3 .mp4-->
<mvc:default-servlet-handler/>
<!--支持MVC注解驱动
在spring中一般采用@RequestMapping注解来完成映射关系
要想使@RequestMapping注解生效
必须向上下文中注册DefaultAnnotationHandlerMapping
和一个AnnotationMethodHandlerAdapter实例
和两个实例分别在类级别和方法级别处理
而annotation-driven配置帮助我们自动完成上述两个实例的注入-->
<mvc:annotation-driven/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
配置整合三层的xml文件的总文件
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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:annotation-config/>
<import resource="spring-service.xml"/>
<import resource="spring-dao.xml"/>
<import resource="springmvc-servlet.xml"/>
</beans>
配置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,这个是springmvc的核心,请求分发器,前端控制器-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!--要绑定springMVC的配置文件 加载的是总的配置文件-->
<param-value>classpath:ApplicationContext.xml</param-value>
</init-param>
<!--启动级别 1服务器启动就启动-->
<load-on-startup>1</load-on-startup>
</servlet>
<!--
/ 只匹配所有的请求不会匹配jsp页面
/* 既匹配所有的请求也会匹配jsp页面 //可能会造成无限jsp循环-->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--配置过滤器过滤乱码问题-->
<filter>
<filter-name>encoding</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>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
9.编写Controller层
package com.ji.controller;
import com.ji.pojo.Books;
import com.ji.service.BookService;
import com.ji.service.BookServiceImpl;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
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.ui.ModelMap;
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 BookController {
//controller层调用service层
@Autowired
@Qualifier("BookServiceImpl")
private BookService bookService;
//查询全部书记,并返回一个书籍展示页面
@RequestMapping("/allBook")
public String list(Model model)
{
List<Books> list=bookService.queryAllBooks ();
model.addAttribute ("list",list);
return "allBooks";
}
//跳转到增加书籍页面
@RequestMapping("/toAddBook")
public String toAddPaper()
{
return "addBook";
}
//添加书籍请求
@RequestMapping("/addBook")
public String addBook(Books books)
{
System.out.println (books);
bookService.addBook (books);
return "redirect:/book/allBook";//重定向到我们的@RequestMapping("allBook")请求
}
@RequestMapping("/toUpdate")
public String toUpdateBook(int id,Model model)
{
Books books = bookService.queryBooks (id);
model.addAttribute ("QueryBooks",books);
return "updateBook";
}
@RequestMapping("/updateBook")
public String UpdateBook(Books books)
{
System.out.println (books);
int i = bookService.updateBooks (books);
if(i>0) System.out.println ("successful");
else System.out.println ("failed");
return "redirect:/book/allBook";
}
//删除书籍
@RequestMapping("/deleteBook/{bookId}")
public String deleteBook(@PathVariable("bookId") int id)
{
bookService.deleteBooks (id);
return "redirect:/book/allBook";
}
//查询书籍
@RequestMapping("QueryBook")
public String queryBook(String queryBookName,Model model)
{
List<Books> books = bookService.queryBookByName (queryBookName);
if(books.size ()==0)
{
List <Books> list=bookService.queryAllBooks ();
model.addAttribute ("list",list);
model.addAttribute ("error","未查到");
return "allBooks";
}
List <Books> list=new ArrayList<Books> ();
list=books;
model.addAttribute ("list",list);
return "allBooks";
}
}
10.编写jsp文件
主页面 index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<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: deeppink;
border-radius: 10px;
}
</style>
</head>
<body>
<h3>
<a href="${pageContext.request.contextPath}/book/allBook">进入书籍页面</a>
</h3>
</body>
</html>
全部书籍页面 allBooks.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="http://cdn.static.runoob.com/libs/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>
<div class="page-header">
<h1>
<small>书籍列表</small>
</h1>
</div>
<div class="row">
<div class="col-md-4 column">
<a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增书籍</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="queryBookName" class="form-control" placeholder="请输入要查询的书籍">
<input type="submit" value="查询" class="btn btn-primary">
</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>
<%--书籍从数据库中查出,从这个list中遍历--%>
<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>
|
<a href="${pageContext.request.contextPath}/book/deleteBook/${book.bookID}">删除</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
增加书籍页面 addBooks.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</title>
<link href="http://cdn.static.runoob.com/libs/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>
<div class="page-header">
<h1>
<small>新增书籍</small>
</h1>
</div>
</div>
<form action="${pageContext.request.contextPath}/book/addBook" method="post">
<div class="form-group">
<label>书籍名称:</label>
<input type="text" name="bookName" class="form-control" required>
<label>书籍数量:</label>
<input type="text" name="bookCounts" class="form-control" required>
<label>书籍描述:</label>
<input type="text" name="detail" class="form-control" required>
</div>
<div class="form-group">
<input type="submit" class="form-control" value="添加">
</div>
</form>
</div>
</body>
</html>
更新书籍页面 updateBooks.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</title>
<link href="http://cdn.static.runoob.com/libs/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>
<div class="page-header">
<h1>
<small>修改书籍</small>
</h1>
</div>
</div>
<form action="${pageContext.request.contextPath}/book/updateBook" method="post">
<%--提交修改sql请求但是修改失败,初次考虑是事务问题,配置完毕事务,依旧修改失败
看一下sql语句能否执行成功 从前端传递隐藏域--%>
<input type="hidden" name="bookID" value="${QueryBooks.bookID}">
<div class="form-group">
<label>书籍名称:</label>
<input type="text" name="bookName" class="form-control" value="${QueryBooks.bookName}" required>
<label>书籍数量:</label>
<input type="text" name="bookCounts" class="form-control" value="${QueryBooks.bookCounts}" required>
<label>书籍描述:</label>
<input type="text" name="detail" class="form-control" value="${QueryBooks.detail}" required>
</div>
<div class="form-group">
<input type="submit" class="form-control" value="修改">
</div>
</form>
</div>
</body>
</html>
注意
引入新jar包时,需要将jar打包到war包中
文件-》项目结构-》artifacts
在WEB-INF下新建web目录将所用jar包导入