当前位置:网站首页>Comprehensive training of large projects
Comprehensive training of large projects
2022-06-10 13:11:00 【I like red grapefruit very much】
Catalog
Add class options when adding students
Resource site used
Day31--SpringBoot (yinxiang.com)
webapp Folders with small circles
https://app.yinxiang.com/fx/9cba161f-7614-42be-93cd-651374fa9658
Gitee:Gitee - be based on Git Code hosting and R & D collaboration platform
layui: Forms - The online demo - Layui (itze.cn)
Statistical charts :
Get into lombook Dependency can reduce the number of getter and setter Function writing
mapper Directly interact with the database in
If you need to jump out of a new window or page , So you need to be in WEB-INF New China jsp file , Corresponding to the new interface / window , And then in controller Add a method to the layer , Use requestMapping annotation , Forward to the corresponding page
If you want to return to a page , that controller Layer does not need requestBody annotation
Concrete realization
json
Use ajex, General interface return data will be encapsulated as JSON Format
JSON Often used with XML compare , because JSON In fact, the birth of the new century has to be replaced more or less XNL It means . comparison XML,JSON The advantages are as follows :
- No end tag , Shorter length , Read and write faster
- Can be directly JavaScript Interpreter parsing
- You can use arrays
Ajex What is it? ?
(70 Bar message ) Just read this one !-Ajax Detailed explanation _ A fish sleeping with a cat _ The blog of -CSDN Blog
It is used when the front and back ends need to transfer data

Merge tables
select *
from student as s inner join banji as b
on s.banji_id=b.id;Interceptor
Two new packages :config Under bag WebConfigurer.java and Interceptor Under bag LoginInterceptor.java
Rights management
Use... In the interface display if Judge
If in index.jsp in , Do not want non administrators to see the user management bar , So only user.typ==0 This column is displayed only when , Otherwise it doesn't show
<c:if test="${user.type==0}">
<dd>
<a href="javascript:;"
data-url="/user/getUserListPage"
class="site-demo-active"> user </a>
</dd>
</c:if>Plaintext encryption
Import in the project MD5util.java Tool class
stay UserServiceImpl in
public void add(User user) {
// Set plaintext encryption for passwords
user.setPassword(MD5Util.MD5Encode(user.getPassword()));
userMapper.add(user);
}When adding a new user , The password entered will be automatically encrypted and saved in the database
How to compare the password entered during login with the password encrypted in the database ?
The password for login is also encrypted
stay UserServiceImpl in
@Override
public User login(String name, String password) {
return userMapper.login(name,MD5Util.MD5Encode(password));
}After setting clear text login , The user's password becomes an encrypted unordered string state

If you want to add users in the background database , You need to put the password you want to enter in MD5 Encrypt in the website , And save it in the database
Add salt
public void add(User user) {
// When adding users , Set plaintext encryption for passwords
// Add “ salt ”, Add a string after the encrypted string , It can make the encryption more efficient
user.setPassword(MD5Util.MD5Encode(user.getPassword()+MD5Util.salt));
userMapper.add(user);
}Salt value on MD5Util In the tool class
public class MD5Util {
// Salt value , Strengthen the encryption of passwords
public static String salt = "sdut*55//66";
……
}Add class options when adding students
1. studentController Medium getStudentAddPage Method , You need to get a list of all the class names list, So use model Open up memory to save all class names obtained from the background
@RequestMapping("/getStudentAddPage")
public String getStudentAddPage(Model model){
List<Banji> banjiList=banjiService.selectAll();
model.addAttribute("banjiList",banjiList);
return "/WEB-INF/student_add.jsp";
}2. Student Classes should be added to entity classes id Properties of :banjiId
3. stay student.add Add a drop-down box to the div label , Just existed model The class name in the memory can be used for Loop it out
value On behalf of the class id Value
<%-- When adding a student, select the student class from the drop-down box --%>
<div class="layui-form-item">
<label class="layui-form-label"> class </label>
<div class="layui-input-block">
<%-- banjiId:1 --%>
<select name="banjiId">
<option>-- Please select ---</option>
<%-- Use for Loop to show all the class names --%>
<c:forEach items="${banjiList}" var="banji">
<option value=${banji.id}>${banji.name}</option>
</c:forEach>
</select>
</div>
</div>4. When adding students, you need to put the students' classes id And add it , So we need to change studentMapper.xml Medium add Method , Add a... To the data sheet banji_id,value To add a banjiId Properties of
<!--void add(Student student);-->
<insert id="add" parameterType="Student">
insert into student(name,age,gender,banji_id) values(#{name},#{age},#{gender},#{banjiId})
</insert>League table query
1. I want to display the student information and the class name in the student list display page . Because the class is saved in the student table id, class id The corresponding class name needs to be found in the class table , So search sql Statement needs to use inner join key word .
<select id="selectByPage" resultType="StudentVo">
-- League table query
select s.id,s.name,s.age,s.gender,s.banji_id,b.name as banjiName
from student as s inner join banji as b
<where>
<if test="student.id!=null">
and id=#{student.id}
</if>
<!--like Fuzzy search concat:-->
<if test="student.name!=null and student.name!=''">
and name like concat('%',#{student.name},'%')
</if>
</where>
limit #{offset},#{limit}
</select>2. You need to create a new entity class named StudentVo, Used to save students' id, full name , Gender , Age and class name
package com.sdut.springboot.entity;
import lombok.Data;
@Data
public class StudentVo {
private Integer age;
private String gender;
private String name;
private Integer id;
private String banjiName;
}
3. hold controller layer 、service layer 、mapper The return value of the corresponding paging method in the layer is from Student Class to StudentVo class
边栏推荐
- OFFICE技术讲座:标点符号-中文-竖排
- JTAG to Axi master debugging Axi Bram controller
- 不吐不快
- 从解读 BDC 自动生成的代码谈起,讲解 SAPGUI 的程序组成部分试读版
- Dynaslam ii: carefully coupled multi object tracking and slam
- Error:top-left corner pixel must be either opaque white or transparent.
- Altium Allegro PADS到底该选哪个EDA设计软件
- IQR box diagram
- 如何才能把团队给带解散。。。
- Leetcode 96. 不同的二叉搜索樹
猜你喜欢

Code free may event Microsoft low code matrix update; Multiple industry reports released

Leetcode 96. 不同的二叉搜索樹

百度程序员删库被判9个月,手机号一键解绑功能发布,推特再向马斯克妥协,今日更多大新闻在此...

Altium Designer重拾之学习资料推荐

向数据库中注册用户名和密码的功能

JS click the button to slide to the left

2022 ciscn preliminary satool

Introduction to assembly language - Summary

Case sharing and implementation introduction of SAP field service management and wechat integration

GNN is used as the new backbone of the three major tasks of CV, with the same cost performance as CNN, Vit and MLP | Chinese Academy of Sciences & Huawei Noah open source
随机推荐
MySQL service evolution
[flinlk] dynamic Kerberos authentication in Flink pit
【抬杠C#】如何实现接口的base调用
Yet Another Palindrome Partitioning
VDO-SLAM: A Visual Dynamic Object-aware SLAM System 论文阅读
Program, calculate 2/1+3/2+5/3+8/5 Value of. It is required to calculate the sum of the first n items and keep 2 decimal places (starting from the second item of the sequence, the numerator of each it
'setbackgrounddrawable() 'is deprecated, setbackgrounddrawable is obsolete
JS global timer case
VDMA commissioning summary
Stereo Vision-based Semantic 3D Object and Ego-motion Tracking for Autonomous Driving 论文阅读
[deep learning] the credit card fraud anomaly detection based on the deep learning autoencoder is very effective
Unity typewriter to automatically roll text to the bottom of the text box
Wei Lai: "pinches" the data and "pinches" the future
世贸组织MC12重启 议程重点关注全球经济复苏
20年技术老兵放弃大厂CTO头衔!这家创业公司凭什么吸引他?
JS prohibit copying page content
Tidb Primary course experience 8 (Management Maintenance of Clusters, add a tikv Node)
Colmap source code reading notes [1] threading cc
Error:top-left corner pixel must be either opaque white or transparent.
How about the one-stop machine learning opening platform mlflow?