选用SSM框架的原因
在目前的企业级Java应用中,Spring框架是必须的。Struts2框架与Spring的整合问题日益凸显,而Spring MVC作为新一代的MVC框架,因其可以与Spring框架无缝整合的特性收到了越来越多的欢迎。Hibernate框架在面对需要存储过程或者复杂SQL时显得力不从心,不能提供高效的数据库控制。而Mybatis框架作为持久层的框架,虽然需要自己编写SQL语句,但是其对高并发高响应的支持,以及对动态SQL和动态绑定的支持使其脱颖而出。
因此SSM框架(Spring + Spring MVC +Mybatis)逐渐取代了之前广泛使用的SSH框架(Spring + Struts2 + Hibernate),成为了目前使用最多的框架。
1.工程结构
上面新建的四个包:pojo,service,dao,controller,其所存放的分别是:
domain: 存放自定义的java类。如:paper类,user类,book类等,每个类的属性设为private,并提供public属性的getter/setter方法让外界访问
service:定义接口,包含系统所提供的功能。(之后还会在service包下再新建impl包)。
dao:定义接口,包含与数据库进行交互的功能。
controller:控制器,负责接收页面请求,转发和处理。
2.
2.1在这之前要对项目的pom.xml文件进行配置,在此文件中配置项目所需要的jar包。
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>first</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>first Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring.version>5.0.3.RELEASE</spring.version>
<mybatis.version>3.4.4</mybatis.version>
</properties>
<dependencies>
<!-- 单元测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- 第一部分:Spring 配置-->
<!-- Spring core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring DAO -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring mvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- 第二部分:Servlet web -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<!-- 第三部分:数据库和mybatis -->
<!-- 数据库 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- 数据库连接池 -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>
<!-- MyBatis -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<!-- mybatis-spring整合包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<!-- 第四部分:日志 -->
<!-- 实现slf4j接口并整合 -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<finalName>first</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
2.2配置web.xml文件
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<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_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<!-- 配置的是我们spring的主配置文件-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- <welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>-->
<!-- spring监听器 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 加载springmvc的主配置-->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- 访问DispatcherServlet对应的路径 -->
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern> <!--/不过滤jsp防止死循环-->
</servlet-mapping>
<!-- 转码-->
<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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
2.3配置applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
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.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<!--配置扫描-->
<context:component-scan base-package="com.qf"></context:component-scan>
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--连接数据库的必备信息-->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydb03"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!--开启spring对注解AOP的支持-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- 配置注解事务开启-->
<tx:annotation-driven />
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.qf.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
</beans>
2.4配置springmvc-servlet.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
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.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<!--配置扫描-->
<context:component-scan base-package="com.qf"></context:component-scan>
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--连接数据库的必备信息-->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydb03"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!--开启spring对注解AOP的支持-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- 配置注解事务开启-->
<tx:annotation-driven />
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.qf.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
</beans>
配置UserMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
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.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<!--配置扫描-->
<context:component-scan base-package="com.qf"></context:component-scan>
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--连接数据库的必备信息-->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydb03"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
</bean>
<!--开启spring对注解AOP的支持-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<!-- 配置注解事务开启-->
<tx:annotation-driven />
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.qf.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
</beans>
3.编写java代码
3.1创建实体类
package com.qf.domain;/**
* Created by HP on 2019/5/23.
*/
import org.springframework.stereotype.Component;
/**
* @author HP liuchenglong
* @create 2019-05-23 19:35
**/
@Component
public class User {
private int id;
private String name;
private String sex;
private int age;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
", sex='" + sex + '\'' +
", age=" + age +
'}';
}
}
**3.2创建dao层接口,编写方法**
package com.qf.dao;
import com.qf.domain.User;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by HP on 2019/5/23.
*/
@Repository
public interface UserDao {
List<User> selectAll();
void insertUser(User user);
void deleteById(int id);
void updateuser(User user);
User selectByid(int id);
List<User> selectById(int id);
}
3.3创建service接口 及实现类
package com.qf.service;
import com.qf.domain.User;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by HP on 2019/5/23.
*/
@Service
public interface UserService {
List<User> selectAll();
void insertUser(User user);
void deleteById(int id);
void updateuser(User user);
List<User> selectById(int id);
User selectByid(int id);
}
实现service
package com.qf.service.impl;/**
* Created by HP on 2019/5/23.
*/
import com.qf.dao.UserDao;
import com.qf.domain.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author HP liuchenglong
* @create 2019-05-23 19:35
**/
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public List<User> selectAll() {
return userDao.selectAll();
}
@Override
public void insertUser(User user) {
userDao.insertUser(user);
}
@Override
public void deleteById(int id) {
userDao.deleteById(id);
}
@Override
public void updateuser(User user) {
userDao.updateuser(user);
}
@Override
public List<User> selectById(int id) {
return userDao.selectById(id);
}
@Override
public User selectByid(int id) {
return userDao.selectByid(id);
}
}
3.4 编写Controller层
package com.qf.controller;/**
* Created by HP on 2019/5/23.
*/
import com.qf.domain.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
/**
* @author HP liuchenglong
* @create 2019-05-23 19:34
**/
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping("/select")
public ModelAndView selectAll() {
List<User> users = userService.selectAll();
System.out.println(users);
ModelAndView md = new ModelAndView();
md.setViewName("user");
md.addObject("users", users);
return md;
}
/**
* 跳转到添加用户界面
* @param
* @return
*/
@RequestMapping("/toAddUser")
public String toAddUser(){
return "/adduser";
}
/**
* 添加用户并重定向
* @param user
* @param
* @return
*/
@RequestMapping("/adduser")
public String addUser(User user){
/* user.getName();
user.getSex();
user.getAge();*/
userService.insertUser(user);
return "redirect:/user/select";
}
@RequestMapping("/del/{id}")
public String deleteUser(@PathVariable("id") int id) {
userService.deleteById(id);
return "redirect:/user/select";
}
@RequestMapping("toUpdateUser")
public String toUpdateUser(Model model, int id) {
model.addAttribute("user",userService.selectByid(id));
return "exituser";
}
@RequestMapping("/exituser")
public String updateUser(Model model, User user) {
userService.updateuser(user);
User user1 = userService.selectByid(user.getId());
model.addAttribute("user", user1);
return "redirect:/user/select";
}
@RequestMapping( value = "/selectbyid")
public ModelAndView selectByid( int id){
List<User> users = userService.selectById(id);
System.out.println(users);
ModelAndView md=new ModelAndView();
md.setViewName("user");
md.addObject("users",users);
return md;
}
}
4 . jsp界面,页面简单就行
4.1修改index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
<h2>欢迎进入用户查询</h2>
<a href="${pageContext.request.contextPath}/user/select">点击跳转</a>
</body>
</html>
4.2 展示用户界面 user.jsp (包括删除及跳转修改)
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: HP
Date: 2019/5/23
Time: 19:48
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<!-- Bootstrap -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<head>
<title>Title</title>
</head>
<body>
<form>
<table class="table table-bordered">
<caption><h1>用户展示</h1>
<form action="user/selectbyid" method="post">
<div >
<input type="button" onclick="selectByid()" value="查询" class="btn btn-primary">
<input type="text"name="id"value="${user.id}">
</div>
</form>
</caption>
<thead>
<tr>
<th><input type="checkbox" id="selectAll"/></th>
<th>序号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:forEach items="${users}" var="user" varStatus="id">
<tr>
<td><input type="checkbox" name="ids" value="${user.id}"/></td>
<td>${id.count}</td>
<td>${user.name}</td>
<td>${user.sex}</td>
<td>${user.age}</td>
<td >
<a href="${pageContext.request.contextPath}/user/toUpdateUser?id=${user.id}">更改</a> |
<a href="${pageContext.request.contextPath}/user/del/${user.id}">删除</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<div style="margin-left: 550px">
<input type="button" value="添加新用户" onclick="adduser()" class="btn btn-primary">
</div>
</form>
<script type="text/javascript">
function adduser() {
var form = document.forms[0];
form.action = "${pageContext.request.contextPath}/user/toAddUser";
form.method = "post";
form.submit();
}
function selectByid() {
var form = document.forms[0];
form.action = "${pageContext.request.contextPath}/user/selectbyid";
form.method = "post";
form.submit();
}
</script>
</body>
</html>
4.3 增加用户界面 adduser.jsp
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
Created by IntelliJ IDEA.
User: HP
Date: 2019/5/23
Time: 20:51
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!-- Bootstrap -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<html>
<head>
<title>用户增加</title>
</head>
<body>
<form action="" name="userForm">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">姓名</span>
<input type="text" class="form-control" name="name" placeholder="" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">性别</span>
<input type="text" class="form-control" name="sex" placeholder="" aria-describedby="basic-addon2">
</div>
<div class="input-group">
<span class="input-group-addon">年龄</span>
<input type="text" class="form-control" name="age" aria-label="Amount (to the nearest dollar)">
</div>
<div style="margin-left: 550px">
<input type="button" value="添加" onclick="adduser()" class="btn btn-primary">
</div>
</form>
<script type="text/javascript">
function adduser() {
var form = document.forms[0];
form.action = "${pageContext.request.contextPath}/user/adduser";
form.method = "post";
form.submit();
}
</script>
</body>
</html>
4.4 修改界面 exituser.jsp
<%--
Created by IntelliJ IDEA.
User: HP
Date: 2019/5/24
Time: 8:10
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<!-- Bootstrap -->
<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<head>
<title>修改</title>
</head>
<body>
<form action="" name="userForm">
<input type="hidden" name="id" value="${user.id}"/>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">姓名</span>
<input type="text" class="form-control"name="name" value="${user.name}" placeholder="" aria-describedby="basic-addon1">
</div>
<div class="input-group">
<span class="input-group-addon" id="basic-addon2">性别</span>
<input type="text" class="form-control"name="sex"value="${user.sex}" placeholder="" aria-describedby="basic-addon2">
</div>
<div class="input-group">
<span class="input-group-addon">年龄</span>
<input type="text" class="form-control" name="age" value="${user.age}" aria-label="Amount (to the nearest dollar)">
</div>
<div style="margin-left: 550px">
<input type="button" value="修改" onclick="updateuser()" class="btn btn-primary">
</div>
</form>
<script type="text/javascript">
function updateuser() {
var form = document.forms[0];
form.action = "${pageContext.request.contextPath}/user/exituser";
form.method = "post";
form.submit();
}
</script>
</body>
</html>
然后运行tomcat服务器可以看到效果
进入界面
展示界面
增加页面
修改页面
至此,利用IDEA+Maven+SSM框架实现的简单的增、删、改、查功能已经构建完毕!