目录
pom.xml
- "1.0" encoding="UTF-8"?>
-
"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">
-
4.0.0 -
-
org.example -
xisslzy_ssm -
1.0-SNAPSHOT -
war -
-
xisslzy_ssm Maven Webapp -
-
http://www.example.com -
-
UTF-8 -
1.8 -
1.8 -
3.7.0 -
-
-
5.0.2.RELEASE -
-
3.4.5 -
-
5.1.44 -
-
5.1.2 -
-
1.3.1 -
-
2.1.1 -
2.4.3 -
-
2.9.1 -
-
4.12 -
4.0.0 -
1.18.2 -
-
-
-
-
org.springframework -
spring-context -
${spring.version} -
-
-
org.springframework -
spring-orm -
${spring.version} -
-
-
org.springframework -
spring-tx -
${spring.version} -
-
-
org.springframework -
spring-aspects -
${spring.version} -
-
-
org.springframework -
spring-web -
${spring.version} -
-
-
org.springframework -
spring-test -
${spring.version} -
-
-
-
org.mybatis -
mybatis -
${mybatis.version} -
-
-
-
mysql -
mysql-connector-java -
${mysql.version} -
-
-
-
com.github.pagehelper -
pagehelper -
${pagehelper.version} -
-
-
-
org.mybatis -
mybatis-spring -
${mybatis.spring.version} -
-
-
-
org.apache.commons -
commons-dbcp2 -
${commons.dbcp2.version} -
-
-
org.apache.commons -
commons-pool2 -
${commons.pool2.version} -
-
-
-
-
org.apache.logging.log4j -
log4j-core -
${log4j2.version} -
-
-
org.apache.logging.log4j -
log4j-api -
${log4j2.version} -
-
-
-
org.apache.logging.log4j -
log4j-web -
${log4j2.version} -
-
-
-
junit -
junit -
${junit.version} -
-
-
javax.servlet -
javax.servlet-api -
${servlet.version} -
provided -
-
-
org.projectlombok -
lombok -
${lombok.version} -
provided -
-
-
org.springframework -
spring-webmvc -
${spring.version} -
-
-
-
javax.servlet.jsp -
javax.servlet.jsp-api -
2.3.3 -
-
-
jstl -
jstl -
1.2 -
-
-
taglibs -
standard -
1.1.2 -
-
-
-
xisslzy_ssm -
-
-
-
src/main/java -
-
**/*.xml -
-
-
-
-
src/main/resources -
-
jdbc.properties -
*.xml -
-
-
-
-
-
org.mybatis.generator -
mybatis-generator-maven-plugin -
1.3.2 -
-
-
-
mysql -
mysql-connector-java -
5.1.44 -
-
-
-
true -
-
-
-
maven-clean-plugin -
3.1.0 -
-
-
-
maven-resources-plugin -
3.0.2 -
-
-
maven-compiler-plugin -
3.8.0 -
-
-
maven-surefire-plugin -
2.22.1 -
-
-
maven-war-plugin -
3.2.2 -
-
-
maven-install-plugin -
2.5.2 -
-
-
maven-deploy-plugin -
2.8.2 -
-
-
web.xml
- "1.0" encoding="UTF-8"?>
"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_3_1.xsd"
- version="3.1">
-
Archetype Created Web Application -
-
-
-
contextConfigLocation -
classpath:spring-context.xml -
-
-
-
org.springframework.web.context.ContextLoaderListener -
-
-
-
-
-
encodingFilter -
org.springframework.web.filter.CharacterEncodingFilter -
true -
-
encoding -
UTF-8 -
-
-
-
encodingFilter -
/* -
-
-
-
SpringMVC -
org.springframework.web.servlet.DispatcherServlet -
-
-
contextConfigLocation -
classpath:spring-mvc.xml -
-
1 -
-
true -
-
-
SpringMVC -
/ -
jdbc.properties
- jdbc.driver=com.mysql.jdbc.Driver
- jdbc.url=jdbc:mysql://localhost/mybatis_ssm?useUnicode=true&characterEncoding=UTF-8
- jdbc.username=root
- jdbc.password=123456
-
generatorConfig.xml
- "1.0" encoding="UTF-8" ?>
- "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
- "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
-
-
"jdbc.properties"/> -
-
-
"D:\\maven\\mvn_repository\\mysql\mysql-connector-java\\5.1.44\\mysql-connector-java-5.1.44.jar"/> -
-
-
"infoGuardian"> -
-
-
"suppressAllComments" value="true"/> -
"suppressDate" value="true"/> -
-
-
-
"${jdbc.driver}" - connectionURL="${jdbc.url}" userId="${jdbc.username}" password="${jdbc.password}"/>
-
-
-
-
-
"forceBigDecimals" value="false"/> -
-
-
-
-
-
"com.xissl.model" - targetProject="src/main/java">
-
-
"enableSubPackages" value="false"/> -
-
"constructorBased" value="true"/> -
-
"trimStrings" value="false"/> -
-
"immutable" value="false"/> -
-
-
-
"com.xissl.mapper" - targetProject="src/main/java">
-
-
"enableSubPackages" value="false"/> -
-
-
-
-
-
-
"com.xissl.mapper" - targetProject="src/main/java" type="XMLMAPPER">
-
-
"enableSubPackages" value="false"/> -
-
-
-
"" tableName="t_mysql_student" domainObjectName="Student"- enableCountByExample="false" enableDeleteByExample="false"
- enableSelectByExample="false" enableUpdateByExample="false">
-
-
-
-
-
spring-mvc.xml
- "1.0" encoding="UTF-8"?>
"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: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/aop http://www.springframework.org/schema/aop/spring-aop-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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
-
-
package="com.xissl"/> -
-
-
-
-
-
"org.springframework.web.servlet.view.InternalResourceViewResolver"> -
-
"viewClass" - value="org.springframework.web.servlet.view.JstlView">
-
"prefix" value="/WEB-INF/jsp/"/> -
"suffix" value=".jsp"/> -
-
-
-
实体类
- package com.xissl.model;
-
- import lombok.ToString;
-
- @ToString
- public class Student {
- private String sid;
-
- private String sname;
-
- private String sage;
-
- private String ssex;
-
- public Student(String sid, String sname, String sage, String ssex) {
- this.sid = sid;
- this.sname = sname;
- this.sage = sage;
- this.ssex = ssex;
- }
-
- public Student() {
- super();
- }
-
- public String getSid() {
- return sid;
- }
-
- public void setSid(String sid) {
- this.sid = sid;
- }
-
- public String getSname() {
- return sname;
- }
-
- public void setSname(String sname) {
- this.sname = sname;
- }
-
- public String getSage() {
- return sage;
- }
-
- public void setSage(String sage) {
- this.sage = sage;
- }
-
- public String getSsex() {
- return ssex;
- }
-
- public void setSsex(String ssex) {
- this.ssex = ssex;
- }
- }
mapper接口
- package com.xissl.mapper;
-
- import com.xissl.model.Student;
- import org.springframework.stereotype.Repository;
-
- import java.util.List;
-
- @Repository
- public interface StudentMapper {
- int deleteByPrimaryKey(String sid);
-
- int insert(Student record);
-
- int insertSelective(Student record);
-
- Student selectByPrimaryKey(String sid);
-
- int updateByPrimaryKeySelective(Student record);
-
- int updateByPrimaryKey(Student record);
-
- List
listPager(Student student); - }
sql映射文件
- "1.0" encoding="UTF-8" ?>
- "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
"com.xissl.mapper.StudentMapper" > -
"BaseResultMap" type="com.xissl.model.Student" > -
-
"sid" jdbcType="VARCHAR" javaType="java.lang.String" /> -
"sname" jdbcType="VARCHAR" javaType="java.lang.String" /> -
"sage" jdbcType="VARCHAR" javaType="java.lang.String" /> -
"ssex" jdbcType="VARCHAR" javaType="java.lang.String" /> -
-
-
"Base_Column_List" > - sid, sname, sage, ssex
-
-
- select
-
"Base_Column_List" /> - from t_mysql_student
- where sid = #{sid,jdbcType=VARCHAR}
-
-
-
- select
-
"Base_Column_List" /> - from t_mysql_student
-
- <if test="sname != null">
- and sname like concat('%',#{sname},'%')
- if>
-
-
-
-
-
"deleteByPrimaryKey" parameterType="java.lang.String" > - delete from t_mysql_student
- where sid = #{sid,jdbcType=VARCHAR}
-
-
"insert" parameterType="com.xissl.model.Student" > - insert into t_mysql_student (sid, sname, sage,
- ssex)
- values (#{sid,jdbcType=VARCHAR}, #{sname,jdbcType=VARCHAR}, #{sage,jdbcType=VARCHAR},
- #{ssex,jdbcType=VARCHAR})
-
-
"insertSelective" parameterType="com.xissl.model.Student" > - insert into t_mysql_student
-
"(" suffix=")" suffixOverrides="," > - <if test="sid != null" >
- sid,
- if>
- <if test="sname != null" >
- sname,
- if>
- <if test="sage != null" >
- sage,
- if>
- <if test="ssex != null" >
- ssex,
- if>
-
-
"values (" suffix=")" suffixOverrides="," > - <if test="sid != null" >
- #{sid,jdbcType=VARCHAR},
- if>
- <if test="sname != null" >
- #{sname,jdbcType=VARCHAR},
- if>
- <if test="sage != null" >
- #{sage,jdbcType=VARCHAR},
- if>
- <if test="ssex != null" >
- #{ssex,jdbcType=VARCHAR},
- if>
-
-
-
"updateByPrimaryKeySelective" parameterType="com.xissl.model.Student" > - update t_mysql_student
-
- <if test="sname != null" >
- sname = #{sname,jdbcType=VARCHAR},
- if>
- <if test="sage != null" >
- sage = #{sage,jdbcType=VARCHAR},
- if>
- <if test="ssex != null" >
- ssex = #{ssex,jdbcType=VARCHAR},
- if>
-
- where sid = #{sid,jdbcType=VARCHAR}
-
-
"updateByPrimaryKey" parameterType="com.xissl.model.Student" > - update t_mysql_student
- set sname = #{sname,jdbcType=VARCHAR},
- sage = #{sage,jdbcType=VARCHAR},
- ssex = #{ssex,jdbcType=VARCHAR}
- where sid = #{sid,jdbcType=VARCHAR}
-
业务逻辑层
- package com.xissl.biz;
-
- import com.xissl.model.Student;
- import com.xissl.utils.PageBean;
-
- import java.util.List;
-
- public interface StudentBiz {
- int deleteByPrimaryKey(String sid);
-
- int insert(Student record);
-
- int insertSelective(Student record);
-
- Student selectByPrimaryKey(String sid);
-
- int updateByPrimaryKeySelective(Student record);
-
- int updateByPrimaryKey(Student record);
-
- List
listPager(Student student, PageBean pageBean); - }
实现接口
- package com.xissl.biz.impl;
-
- import com.xissl.biz.StudentBiz;
- import com.xissl.mapper.StudentMapper;
- import com.xissl.model.Student;
- import com.xissl.utils.PageBean;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
-
- import java.util.List;
-
- /**
- * @author xissl
- * @create 2023-09-07 16:07
- */
- @Service
- public class StudentBizImpl implements StudentBiz {
-
- @Autowired
- private StudentMapper studentMapper;
-
- @Override
- public int deleteByPrimaryKey(String sid) {
- return studentMapper.deleteByPrimaryKey(sid);
- }
-
- @Override
- public int insert(Student record) {
- return studentMapper.insert(record);
- }
-
- @Override
- public int insertSelective(Student record) {
- return studentMapper.insertSelective(record);
- }
-
- @Override
- public Student selectByPrimaryKey(String sid) {
- return studentMapper.selectByPrimaryKey(sid);
- }
-
- @Override
- public int updateByPrimaryKeySelective(Student record) {
- return studentMapper.updateByPrimaryKeySelective(record);
- }
-
- @Override
- public int updateByPrimaryKey(Student record) {
- return studentMapper.updateByPrimaryKey(record);
- }
-
- @Override
- public List
listPager(Student student, PageBean pageBean) { - return studentMapper.listPager(student);
- }
- }
controller层
- package com.xissl.web;
-
- import com.xissl.biz.StudentBiz;
- import com.xissl.model.Student;
- import com.xissl.utils.PageBean;
- import lombok.extern.slf4j.Slf4j;
- 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 javax.servlet.http.HttpServletRequest;
- import java.util.List;
-
- /**
- * @author xissl
- * @create 2023-09-07 16:59
- */
- @Controller
- @RequestMapping("/stu")
- public class StudentController {
- @Autowired
- private StudentBiz studentBiz;
- // 增
- @RequestMapping("/add")
- public String add(Student student){
- int i = studentBiz.insertSelective(student);
- return "redirect:list";
- }
- // 删
- @RequestMapping("/del")
- public String del(String sid){
- studentBiz.deleteByPrimaryKey(sid);
- return "redirect:/stu/list";
- }
- // 改
- @RequestMapping("/edit")
- public String edit(Student student){
- studentBiz.updateByPrimaryKey(student);
- return "redirect:list";
-
- }
- // 查
- @RequestMapping("/list")
- public String list(Student student, HttpServletRequest request){
- // Student student是前台用来给后台传递参数的
- PageBean pageBean = new PageBean();
- pageBean.setRequest(request);
- List
students = studentBiz.listPager(student, pageBean); - request.setAttribute("list",students);
- request.setAttribute("pageBean",pageBean);
- return "stu/list";
- }
- // 数据回显
- @RequestMapping("/preSave")
- public String preSave(Student student, Model model){
- if(student != null && student.getSid()!=null){
- Student s = studentBiz.selectByPrimaryKey(student.getSid());
- model.addAttribute("s",s);
- }
- return "stu/edit";
- }
- }
list.jsp
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <%@ taglib uri="http://jsp.veryedu.cn" prefix="z"%>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
- "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- "Content-Type" content="text/html; charset=UTF-8">
-
- href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.css"
- rel="stylesheet">
-
- src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.js">
-
博客列表 -
- action="${pageContext.request.contextPath }/stu/list" method="post">
- "form-group mb-2">
- "text" class="form-control-plaintext" name="sname"
- placeholder="请输入学生姓名">
-
-
- <%-- "pagination" value="false" type="hidden">--%>
-
-
-
"table table-striped">-
-
-
"col">学生编号 -
"col">学生姓名 -
"col">学生年龄 -
"col">学生性别 -
"col">操作 -
-
-
-
var="b" items="${list }"> -
-
${b.sid } -
${b.sname } -
${b.sage } -
${b.ssex } -
-
-
"${pageBean }"> -
edit.jsp
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
-
Title - 学生编号:"text" name="sid" value="${s.sid }">
- 学生姓名:"text" name="sname" value="${s.sname }">
- 学生年龄:"text" name="sage" value="${s.sage }">
- 学生性别:"text" name="ssex" value="${s.ssex }">
- "submit">
-
相关阅读:
MapStruct的使用
C. Target Practice
电脑多位置同时输入方法
这几个 Python 小游戏,上班摸鱼我能玩一天 | 内附源码
深度学习之目标检测模型后处理(非极大值抑制与WBF)
MySQL之事务、存储引擎、索引
《MLB棒球创造营》:走近棒球运动·旧金山巨人队
怎么判断MES系统好不好?MES又是如何帮企业省钱的?
Linux 安装 CenOS7 MySQL - 8.0.26
Hexagon_V65_Programmers_Reference_Manual(7)
-
原文地址:https://blog.csdn.net/lijie1025/article/details/132742543