SSM框架整合实现增删改查(简单的实现)

SSM框架整合实现增删改查


文件结构
在这里插入图片描述
POM文件

<packaging>war</packaging>
  <!-- 处理乱码 -->
	<properties>
		<!-- 设置项目字符集 -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<!-- spring版本号 -->
		<spring.version>4.3.2.RELEASE</spring.version>
	</properties>
  <dependencies>
  <!--Dao层Mybatis  jar包  -->
  		<!-- mybatis -->
  		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
			<version>3.4.5</version>
		</dependency>
  		<!-- mysql -->
  		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.11</version>
		</dependency>
  		<!-- druid -->
  		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>1.1.8</version>
		</dependency>
	<!-- Service层 Spring -->
		<!-- Spring-context -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-core -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-bean -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-expression -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-tx -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-jbdc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-mybatis -->
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis-spring</artifactId>
			<version>1.3.2</version>
		</dependency>
	<!-- Servlet层SpringMVC -->
		<!-- Spring-web -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- Spring-mvc -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>4.3.2.RELEASE</version>
		</dependency>
		<!-- servlet -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>4.0.1</version>
			<scope>provided</scope>
		</dependency>
		<!-- jsp -->
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>javax.servlet.jsp-api</artifactId>
			<version>2.3.3</version>
			<scope>provided</scope>
		</dependency>
		<!-- jsp.jstl -->
		<dependency>
			<groupId>javax.servlet.jsp.jstl</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<!-- servlet.jstl -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
			<version>1.2</version>
		</dependency>
		<!-- standard -->
		<dependency>
			<groupId>taglibs</groupId>
			<artifactId>standard</artifactId>
			<version>1.1.2</version>
		</dependency>
	<!-- aspect注解 -->
		<!--使用AspectJ方式注解需要相应的包 --> 
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>1.6.11</version>
		</dependency>
		<!--使用AspectJ方式注解需要相应的包 -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>1.6.11</version>
		</dependency>
  </dependencies>
  <!-- Tomcat插件 -->
  		<build>
		<!-- 配置tomcat插件,web端 -->
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<configuration>
					<path>/</path>
					<port>8080</port>
				</configuration>
			</plugin>
		</plugins>
	</build>

Mybatis的XML文件
applicationContext-mybatis.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: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-4.3.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.3.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    
    <!-- 加载数据库配置文件 -->
    <context:property-placeholder location="classpath:druid.properties"/>
    <!-- 配置数据库连接池 -->
    <bean id="dataSource"
		class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
		destroy-method="close">
		<!-- 配置数据库连接基本信息 -->
		<property name="driverClassName" value="${driver}" />
		<property name="url" value="${url}" />
		<property name="username" value="${name}" />
		<property name="password" value="${password}" />
		<!-- ******配置数据库连接池相关信息******* -->
		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="5" />
		<property name="minIdle" value="2" />
		<property name="maxActive" value="10" />
		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="10000" />
		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="60000" />
		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="300000" />
		<property name="testWhileIdle" value="true" />
		<!-- 这里建议配置为TRUE,防止取到的连接不可用 -->
		<property name="testOnBorrow" value="true" />
		<property name="testOnReturn" value="false" />
		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
		<property name="poolPreparedStatements" value="true" />
		<property name="maxPoolPreparedStatementPerConnectionSize"
			value="20" />
		<!-- 这里配置提交方式,默认就是TRUE,可以不用配置 -->
		<property name="defaultAutoCommit" value="true" />
		<!-- 验证连接有效与否的SQL,不同的数据配置不同 -->
		<property name="validationQuery" value="select 1" />
	</bean>
	<!-- sqlsessionFactory -->
	<bean id="sqlSessionFactoryBean"
		class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 注入数据源 -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- 加载mybatis配置文件 -->
		<property name="configLocation" value="classpath:mybatisConfig.xml"></property>
		<!-- 加载映射文件 -->
		<property name="mapperLocations" value="classpath:cn/edu360/mybatis/entity/*.xml"></property>
	</bean>
	<!-- 配置事物管理器 -->
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<!-- 注入数据源 -->
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	<!-- 通过aop管理事务(事务应该做用在service层) -->
	<aop:config proxy-target-class="true">
		<aop:advisor pointcut="execution (* cn.edu360.service.impl.*.*(..))"
			advice-ref="departmentAdvice" />
	</aop:config>
	<!-- 创建一个事物 -->
	<tx:advice id="departmentAdvice"
		transaction-manager="transactionManager">
		<!-- 设置事物的级别和属性 -->
		<tx:attributes>
			<tx:method name="insert*" isolation="READ_COMMITTED"
				propagation="REQUIRED" read-only="false" timeout="-1"
				rollback-for="Exception" />
			<tx:method name="delete*" isolation="READ_COMMITTED"
				propagation="REQUIRED" read-only="false" timeout="-1"
				rollback-for="Exception" />
			<tx:method name="update*" isolation="READ_COMMITTED"
				propagation="REQUIRED" read-only="false" timeout="-1"
				rollback-for="Exception" />
			<tx:method name="select*" propagation="SUPPORTS"
				read-only="false" rollback-for="Exception" />
			<tx:method name="*" isolation="READ_COMMITTED"
				propagation="REQUIRED" timeout="-1" rollback-for="Exception"
				read-only="false" />
		</tx:attributes>
	</tx:advice>
	<!-- 扫描Dao层连接Mybatis的mapper接口 -->
	<bean id="mapperScannerConfigurer"
		class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="cn.edu360.mybatis.mapper"></property>
		<property name="sqlSessionFactoryBeanName"
			      value="sqlSessionFactoryBean"></property>
	</bean>
</beans>

Mybatis配置文件
mybatisConfig.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>

</configuration>

Spring配置文件
applicationContext-spring.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: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-4.3.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.3.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    <!-- 启用classpath扫描 -->
    <context:component-scan base-package="cn.edu360"></context:component-scan>

</beans>

SpringMVC配置文件
springmvc.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: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-4.3.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.3.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
    
    <!-- classpath扫描controller -->
    <context:component-scan base-package="cn.edu360.spring.controller"></context:component-scan>
    <!-- springMVC 视图解析器 -->
    <bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/" />
		<property name="suffix" value=".jsp" />
	</bean>

</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  <display-name>Spring-SpringMVC-Mybatis-ssm</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <!-- 在servlet上下文中配置ioc容器文件 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext-*.xml</param-value>
	</context-param>
	<!-- 通过监听器加载ioc容器 -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<!-- 配置过滤器 -->
	<!-- POST中文乱码过滤器 -->
	<filter>
		<filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 配置前端控制器 -->
	<servlet>
		<servlet-name>DispatcherServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<!-- 默认加载springmvc配置文件【servlet-name】-servlet.xml 位置在WEB-INF下 -->
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:springmvc.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>
</web-app>

实体类

package cn.edu360.mybatis.entity;

public class Department {
	private int department_id;
	private String dname;
	private String daddress;

	public Department(int department_id, String dname, String daddress) {
		super();
		this.department_id = department_id;
		this.dname = dname;
		this.daddress = daddress;
	}

	public Department() {
		super();
	}

	public int getDepartment_id() {
		return department_id;
	}

	public void setDepartment_id(int department_id) {
		this.department_id = department_id;
	}

	public String getDname() {
		return dname;
	}

	public void setDname(String dname) {
		this.dname = dname;
	}

	public String getDaddress() {
		return daddress;
	}

	public void setDaddress(String daddress) {
		this.daddress = daddress;
	}

	@Override
	public String toString() {
		return "Department [department_id=" + department_id + ", dname=" + dname + ", daddress=" + daddress + "]";
	}

}

Mapping映射文件

<?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="cn.edu360.mybatis.mapper.DepartmentMapper">
	<!-- 添加 -->
	<insert id="insertByCount" parameterType="cn.edu360.mybatis.entity.Department">
		insert into department values(null,#{dname},#{daddress})
	</insert>
	<!-- 修改 -->
	<update id="updateByCount" parameterType="cn.edu360.mybatis.entity.Department">
		update department set dname=#{dname},daddress=#{daddress} where department_id=#{department_id}
	</update>
	<!-- 删除 -->
	<delete id="deleteByCount" parameterType="cn.edu360.mybatis.entity.Department">
		delete from department where department_id=#{department_id}
	</delete>
	<!-- 查询全部 -->
	<select id="selectByAll" resultType="cn.edu360.mybatis.entity.Department">
		select * from department
	</select>
	<!-- 模糊查询 -->
	<select id="selectByLike" resultType="cn.edu360.mybatis.entity.Department" parameterType="java.lang.String">
		select * from department where dname like concat('%',#{keyWord},'%')
	</select>
</mapper>

Mapper接口

package cn.edu360.mybatis.mapper;

import java.util.List;

import cn.edu360.mybatis.entity.Department;

public interface DepartmentMapper {
	//对数据库进行添加
	int insertByCount(Department dept);
	//对数据库进行修改
	int updateByCount(Department dept);
	//对数据库进行删除
	int deleteByCount(Department dept);
	//对数据路进行全部查找
	List<Department> selectByAll();
	//对数据库进行模糊查询
	List<Department> selectByLike(String keyWord);
}

Service接口

package cn.edu360.service.inter;

import java.util.List;

import cn.edu360.mybatis.entity.Department;

public interface DepartmentServiceInter {
	String insertByCount(Department dept);
	String updateByCount(Department dept);
	String deleteByCount(Department dept);
	List<Department> selectByAll();
	List<Department> selectByLike(String keyWord);
}

Service实现类

package cn.edu360.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu360.mybatis.entity.Department;
import cn.edu360.mybatis.mapper.DepartmentMapper;
import cn.edu360.service.inter.DepartmentServiceInter;
@Service("departmentServiceImpl")
public class DepartmentServiceImpl implements DepartmentServiceInter {
	@Autowired
	private DepartmentMapper departmentMapper;
	@Override
	public String insertByCount(Department dept) {
		System.out.println("service+++++++++++++++++++++++++++++++++++++++++++++");
		int i = departmentMapper.insertByCount(dept);
		String message="";
		if(i>0) {
			message="添加成功";
		}else {
			message="添加失败";
		}
		return message;
	}

	@Override
	public String updateByCount(Department dept) {
		int i = departmentMapper.updateByCount(dept);
		String message="";
		if(i>0) {
			message="修改成功";
		}else {
			message="修改失败";
		}
		return message;
	}

	@Override
	public String deleteByCount(Department dept) {
		int i = departmentMapper.deleteByCount(dept);
		String message="";
		if(i>0) {
			message="删除成功";
		}else {
			message="删除失败";
		}
		return message;
	}

	@Override
	public List<Department> selectByAll() {
		return departmentMapper.selectByAll();
	}

	@Override
	public List<Department> selectByLike(String keyWord) {
		return departmentMapper.selectByLike(keyWord);
	}

	public DepartmentMapper getDepartmentMapper() {
		return departmentMapper;
	}

	public void setDepartmentMapper(DepartmentMapper departmentMapper) {
		this.departmentMapper = departmentMapper;
	}
	
}

Controller控制层

package cn.edu360.spring.mybatis.test;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.annotations.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.edu360.mybatis.entity.Department;
import cn.edu360.service.impl.DepartmentServiceImpl;
import cn.edu360.service.inter.DepartmentServiceInter;
@Controller
public class SpringMybatisTest { 
	@Autowired
	private  DepartmentServiceInter service;
	@RequestMapping("/insert")
	public String insertByCount(HttpServletRequest req,Department dept) {
		
		dept.setDname(dept.getDname());
		dept.setDaddress(dept.getDaddress());
		System.out.println(dept.toString());
		String insert = service.insertByCount(dept);
		req.setAttribute("insert", insert);
		
		return "/insert";
	}
	@RequestMapping("/select")
	public String selectByAll(HttpServletRequest req){
		List<Department> list = service.selectByAll();
		req.setAttribute("list", list);
		return "/select";
		
	}
	@RequestMapping("/update")
	public String updateByCount(HttpServletRequest req,Department dept) {
		dept.setDname(dept.getDname());
		dept.setDaddress(dept.getDaddress());
		dept.setDepartment_id(dept.getDepartment_id());
		String update = service.updateByCount(dept);
		req.setAttribute("update", update);
		return "/update";
	}
	@RequestMapping("/delete")
	public String deleteByCount(HttpServletRequest req,Department dept) {
		dept.setDepartment_id(dept.getDepartment_id());
		String delete = service.deleteByCount(dept);
		req.setAttribute("delete", delete);
		return "/delete";
	}
}

JSP页面
查询展示页面
在这里插入图片描述

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>部门列表</title>
</head>
<body>
	<table border="solid 1px red;" cellspacing="0px" cellpadding="5px" width="600px" >
		<thead>
			<tr style="text-align: left;">
			<form action="insert.jsp" method="post" enctype="application/x-www-form-urlencoded">
				<td colspan="3">
					<input type="submit" value="添加"/>
				</td>
			</form>
			<form action="delete.jsp" method="post" enctype="application/x-www-form-urlencoded">
				<td colspan="3">
					<input  type="submit" value="删除"/>
				</td>
			</form>
			</tr>
			<tr style="text-align: center;">
				<td><input type="checkbox" id="checkAll"/></td>
				<th>部门ID</th>
				<th>部门名称</th>
				<th>部门地址</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${ list }" var="p">
			<tr style="text-align: center;">
				<td><input type="checkbox" class="checkSimple" value="${ p.department_id }"/></td>
				<th>${ p.department_id }</th>
				<th>${ p.dname }</th>
				<th>${ p.daddress }</th>
				<td><a href="/update.jsp">修改</a></td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</body>
</html>

添加界面
在这里插入图片描述

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加</title>
</head>
<body>
<form action="insert" method="post" enctype="application/x-www-form-urlencoded">
	<table border="solid 1px red;" cellspacing="0px" cellpadding="5px" width="600px" >
		<thead>
			<tr style="text-align: center;">
				<td><input type="checkbox" id="checkAll"/></td>
				<th>部门名称</th>
				<th>部门地址</th>
				<th>商品操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><input type="checkbox" class="checkSimple"/></td>
				<td><input type="text" name="dname" id="dname"></td>
				<td><input type="text" name="daddress" id="daddress"></td>
				<td><input type="submit" id="add" value="添加"/></td>
			</tr>
		</tbody>
	</table>
	<p style="color:red">${insert}</p> 
	</form>
</body>
</html>

更改界面
在这里插入图片描述

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改</title>
</head>
<body>
	<form action="/update" method="post" enctype="application/x-www-form-urlencoded">
	<table border="solid 1px red;" cellspacing="0px" cellpadding="5px" width="600px" >
		<thead>
			<tr style="text-align: center;">
				<td><input type="checkbox" id="checkAll"/></td>
				<th>部门ID</th>
				<th>部门名称</th>
				<th>部门地址</th>
				<th>商品操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><input type="checkbox" class="checkSimple"/></td>
				<td><input type="text" name="department_id" id="department_id"></td>
				<td><input type="text" name="dname" id="dname"></td>
				<td><input type="text" name="daddress" id="daddress"></td>
				<td><input type="submit" id="update" value="修改"/></td>
			</tr>
		</tbody>
	</table>
	<p style="color: red">${update}</p>
	<a href="/select">返回</a>
	</form>
</body>
</html>

删除界面
在这里插入图片描述

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>删除</title>
</head>
<body>
	<form action="/delete" method="post" enctype="application/x-www-form-urlencoded">
	<table border="solid 1px red;" cellspacing="0px" cellpadding="5px" width="600px" >
		<thead>
			<tr style="text-align: center;">
				<td><input type="checkbox" id="checkAll"/></td>
				<th>部门ID</th>
				<th>商品操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td><input type="checkbox" class="checkSimple"/></td>
				<td><input type="text" name="department_id" id="department_id"></td>
				<td><input type="submit" id="delete" value="删除"/></td>
			</tr>
		</tbody>
	</table>
	<p style="color: red">${delete}</p>
	<a href="/select">返回</a>
	</form>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_41303204/article/details/82830521