SET FOREIGN_KEY_CHECKS = 0;
– Table structure for student
DROP TABLE IF EXISTS student
;
CREATE TABLE student
(
id
int(11) NOT NULL AUTO_INCREMENT,
studentName
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
studentNo
int(11) NULL DEFAULT NULL,
age
int(11) NULL DEFAULT NULL,
gender
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
major
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
grade
varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (id
) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
– Records of student
INSERT INTO student
VALUES (2, ‘张美华’, 135654621, 20, ‘0’, ‘计算机应用’, ‘一年级’);
INSERT INTO student
VALUES (3, ‘王子豪’, 5315641, 20, ‘1’, ‘计算机网络技术’, ‘二年级’);
INSERT INTO student
VALUES (4, ‘李玉恒’, 13515681, 19, ‘0’, ‘计算机网络技术’, ‘一年级’);
INSERT INTO student
VALUES (5, ‘王子豪’, 13515681, 19, NULL, ‘计算机网络技术’, ‘二年级’);
SET FOREIGN_KEY_CHECKS = 1;
目录结构
Student
JAR包:
src
com.controller
StudentController.java
package com.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.entity.Student;
import com.services.StudentService;
@Controller
public class StudentController {
@Resource
StudentService studentservice;
@RequestMapping(“student”)
public ModelAndView select(String keyword) {
List selestudent = studentservice.selestudent(keyword);
if (keyword == null || keyword.trim().equals(“”)) {
keyword = “”;
}
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject(“selestudent”, selestudent);
modelAndView.setViewName(“Student”);
return modelAndView;
}
@RequestMapping(“delstu”)
public String delstu(Integer id) {
int delStudent = studentservice.delStudent(id);
return “redirect:/student.do”;
}
@RequestMapping(“addjsp”)
public String addjsp() {
return “addStudent”;
}
@RequestMapping(“add”)
public String add(Student student) {
int add = studentservice.add(student);
return “redirect:/student.do”;
}
}
com.dao
StudentMapper.java
package com.dao;
import com.entity.Student;
import java.util.List;
public interface StudentMapper {
int deleteByPrimaryKey(Integer id);
int insert(Student record);
Student selectByPrimaryKey(Integer id);
List selectAll();
int updateByPrimaryKey(Student record);
List likeStudents(String keyword);
}
StudentMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>delete from student
where id = #{id,jdbcType=INTEGER}
insert into student (id, studentName, studentNo,
age, gender, major,
grade)
values (#{id,jdbcType=INTEGER}, #{studentname,jdbcType=VARCHAR}, #{studentno,jdbcType=INTEGER},
#{age,jdbcType=INTEGER}, #{gender,jdbcType=INTEGER}, #{major,jdbcType=VARCHAR},
#{grade,jdbcType=VARCHAR})
select id, studentName, studentNo, age, gender, major, grade
from student
select id, studentName, studentNo, age, gender, major, grade
from student where studentName like “%”#{keyword}“%”
com.entity
Student.java
package com.entity;
public class Student {
private Integer id;
private String studentname;
private Integer studentno;
private Integer age;
private Integer gender;
private String major;
private String grade;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getStudentname() {
return studentname;
}
public void setStudentname(String studentname) {
this.studentname = studentname == null ? null : studentname.trim();
}
public Integer getStudentno() {
return studentno;
}
public void setStudentno(Integer studentno) {
this.studentno = studentno;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public Integer getGender() {
return gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major == null ? null : major.trim();
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade == null ? null : grade.trim();
}
}
com.service.imp
StudentServiceImp.java
package com.service.imp;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.dao.StudentMapper;
import com.entity.Student;
import com.services.StudentService;
@Service
public class StudentServiceImp implements StudentService {
@Resource
StudentMapper studenmapper;
@Override
public List selestudent(String keyword) {
if (keyword == null || keyword.trim().equals(“”)) {
List selectAll = studenmapper.selectAll();
return selectAll;
} else {
List likeStudents = studenmapper.likeStudents(keyword);
return likeStudents;
}
}
@Override
public int delStudent(Integer id) {
int deleteByPrimaryKey = studenmapper.deleteByPrimaryKey(id);
return deleteByPrimaryKey;
}
@Override
public int add(Student student) {
int insert = studenmapper.insert(student);
return insert;
}
}
com.services
StudentService.java
package com.services;
import java.util.List;
import com.entity.Student;
public interface StudentService {
List selestudent(String keyword);
int delStudent(Integer id);
int add(Student student);
}
mybatis
sqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8"?>spring
applicationContext-dao.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: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.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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">
<context:property-placeholder location=“classpath:jdbc.properties”></context:property-placeholder>
<tx:annotation-driven transaction-manager=“transactionManager” />
applicationContext-service.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”
xmlns:mvc=“http://www.springframework.org/schema/mvc”
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd ">
<context:component-scan base-package=“com” />
spring-mvc.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”
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
![img](https://i-blog.csdnimg.cn/blog_migrate/1327b67ba2a63a08c5f0358060a566be.jpeg)
最后
我还通过一些渠道整理了一些大厂真实面试主要有:蚂蚁金服、拼多多、阿里云、百度、唯品会、携程、丰巢科技、乐信、软通动力、OPPO、银盛支付、中国平安等初,中级,高级Java面试题集合,附带超详细答案,希望能帮助到大家。
还有专门针对JVM、SPringBoot、SpringCloud、数据库、Linux、缓存、消息中间件、源码等相关面试题。
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**[外链图片转存中…(img-opBhxnig-1712896594218)]
[外链图片转存中…(img-3XbofTBU-1712896594219)]
[外链图片转存中…(img-Lejx5Jfd-1712896594219)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)
![img](https://i-blog.csdnimg.cn/blog_migrate/1327b67ba2a63a08c5f0358060a566be.jpeg)
最后
我还通过一些渠道整理了一些大厂真实面试主要有:蚂蚁金服、拼多多、阿里云、百度、唯品会、携程、丰巢科技、乐信、软通动力、OPPO、银盛支付、中国平安等初,中级,高级Java面试题集合,附带超详细答案,希望能帮助到大家。
[外链图片转存中…(img-ZddpbtVb-1712896594220)]
还有专门针对JVM、SPringBoot、SpringCloud、数据库、Linux、缓存、消息中间件、源码等相关面试题。
[外链图片转存中…(img-Q0edtd6K-1712896594220)]
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!