JAVA_GUI之“职工信息管理系统”

2023-11-30 23:50

本文主要是介绍JAVA_GUI之“职工信息管理系统”,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

要求:

(一)任务描述
(1)编写一个具有图形用户界面的程序,实现对职工基本信息的管理:
A、添加职工信息(职工工号、姓名、出生年月、基本工资、email);
B、显示职工信息:从文件中读取所有职工信息并显示出来;
C、修改和删除职工信息:能对已有职工记录(除工号外)进行修改,能删除已有职工记录,操作能同步到文件中。
D、统计计算:统计职工人数、基本工资平均值、最高工资、最低工资对应的职工的完整信息。
E、程序的主窗口标题要包含开发者的信息“职工信息管理系统,开发者:张三(XXX),指导老师:YYY”,凡是没有加这个信息的,直接扣20分。
F、职工工号由系统自动生成,是一个字符串,格式为XXXXYYZZ,其中XXXX、YY分别为系统当前的年和月,ZZ为职工序号,
例如:20210378表示2021年3月添加的序号为78的工号。
(二)编程要求
(1)添加职工信息时,能对输入的合法性进行检查,以Emai为例,要求用户从文本框中输入的Email必须是合法的Emai,年月也必须是合法的年月。
(2)职工的信息永久存储到文件,若需要显示所有职工及对已有职工记录进行修改,都必须从文件中读写,确保程序退出后信息能得到保存。
(3)以MVC模式进行开发,M为模型,即职工信息模型,它具有职工基本属性,还提供职工数据文件的读写方法,V是添加、删除、修改、浏览等操作的界面,C是事件监听器对象,用来处理界面事件,将模型和视图联系起来,实现数据的存取。
(4)要求各个界面美观、所有窗口打开时居于屏幕正中。
(5)参考方案(你也可以有自己的方案)
可以参考下面的UML图完成类的设计。
   

 成果:

 大致类图:(其中的UML类图并不标准,刚学),好分析类与方法

效果图:

        具有添加、删除、修改、查找、展示等功能

  

代码:(因为是写在一个文件下的,所以略显冗杂)

//包
package gui_sy3;import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.FlowLayout;
import java.io.BufferedReader;
import java.io.CharArrayWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;import javax.swing.JButton;
import javax.swing.JFrame;public class Test {//目标文件final String TARGET_FILE = "./temp.txt";File targetFile = new File(TARGET_FILE);public Test() {JFrame jf = new JFrame("职工信息管理系统");jf.setSize(300, 300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);JPanel jp0 = new JPanel();JPanel jp1 = new JPanel();JPanel jp2 = new JPanel();JPanel jp3 = new JPanel();JLabel jl0 = new JLabel();jl0.setText("职工信息管理系统");jl0.setFont(new Font(null, Font.PLAIN, 25));  // 设置字体,null 表示使用默认字体jp0.add(jl0);JLabel jl1 = new JLabel("开发者:2000300420");jp1.setLayout(new FlowLayout(FlowLayout.LEFT)); jl1.setFont(new Font(null, Font.PLAIN, 15));  // 设置字体,null 表示使用默认字体jp1.add(jl1);JLabel jl2 = new JLabel("指导老师:李*辉");jp2.setLayout(new FlowLayout(FlowLayout.LEFT)); jl2.setFont(new Font(null, Font.PLAIN, 15));  // 设置字体,null 表示使用默认字体jp2.add(jl2);       JButton jb0 = new JButton("添加");JButton jb1 = new JButton("浏览");jp3.add(jb0);jp3.add(jb1);// 	添加操作jb0.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {try {add();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}});// 	浏览操作jb1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {try {look();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}});// 创建一个垂直盒子容器, 把上面 3 个 JPanel 串起来作为内容面板添加到窗口Box vBox = Box.createVerticalBox();vBox.add(jp0);vBox.add(jp1);vBox.add(jp2);vBox.add(jp3);jf.setContentPane(vBox);
//        jf.pack();jf.setLocationRelativeTo(null);jf.setVisible(true);}// 添加 -> 窗口public void add() throws IOException {JFrame jf = new JFrame("添加职工");jf.setSize(300, 300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);JPanel jp0 = new JPanel();JLabel jl0 = new JLabel();jl0.setText("请输入新员工信息:");
//    	jl0.setFont(new Font(null, Font.PLAIN, 10));  // 设置字体,null 表示使用默认字体jp0.setLayout(new FlowLayout(FlowLayout.LEFT));jp0.add(jl0);JPanel jp1 = new JPanel();jp1.add(new JLabel("ID:"));JTextField jtext1 = new JTextField(10);jp1.add(jtext1);JPanel jp2 = new JPanel();jp2.add(new JLabel("姓名:"));JTextField jtext2 = new JTextField(10);jp2.add(jtext2);JPanel jp3 = new JPanel();jp3.add(new JLabel("出生年月:"));JTextField jtext3 = new JTextField(10);jp3.add(jtext3);JPanel jp4 = new JPanel();jp4.add(new JLabel("工资:"));JTextField jtext4 = new JTextField(10);jp4.add(jtext4);JPanel jp5 = new JPanel();jp5.add(new JLabel("Email:"));JTextField jtext5 = new JTextField(10);jp5.add(jtext5);// 第 3 个 JPanel, 使用浮动布局, 并且容器内组件居中显示JPanel jp6 = new JPanel(new FlowLayout(FlowLayout.CENTER));JButton jb06 = new JButton("确认添加");jp6.add(jb06);if(targetFile.createNewFile()) {System.out.println("文件不存在,创建成功");}else {System.out.println("文件存在");} //	添加事件jb06.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("确认添加");try {//打开文件字符输出流FileWriter writer = new FileWriter(targetFile,true);//获取文本显示区文本String[][] result = new String[5][2]; result[0][0] = "ID:";result[0][1] = jtext1.getText();result[1][0] = "姓名:";result[1][1] = jtext2.getText();result[2][0] = "出生年月:";result[2][1] = jtext3.getText();result[3][0] = "工资:";result[3][1] = jtext4.getText();result[4][0] = "Email:";result[4][1] = jtext5.getText();//写入文件writer.write("------------\n");for(int i=0;i<5;i++) {for(int j=0;j<2;j++) {writer.write(result[i][j]);}writer.write("\n");}writer.write("\n");writer.flush();//关闭输出流writer.close(); // 消息对话框无返回, 仅做通知作用JOptionPane.showMessageDialog(jf,"添加成功!","添加",JOptionPane.INFORMATION_MESSAGE);} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}});// 创建一个垂直盒子容器, 把上面 3 个 JPanel 串起来作为内容面板添加到窗口Box vBox = Box.createVerticalBox();vBox.add(jp0);vBox.add(jp1);vBox.add(jp2);vBox.add(jp3);vBox.add(jp4);vBox.add(jp5);vBox.add(jp6);jf.setContentPane(vBox);//        jf.pack();jf.setLocationRelativeTo(null);jf.setVisible(true);}//	浏览 -> 窗口public void look() throws IOException {JFrame jf = new JFrame("浏览职工信息");
//    	jf.setSize(300, 300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);// 第 1 个 JPanel, 使用默认的浮动布局JPanel jp0 = new JPanel();jp0.add(new JLabel("请输入ID    "));JTextField jtext0 = new JTextField(5);jp0.add(jtext0);JButton jb0 = new JButton("按ID查找");jp0.add(jb0);jp0.setLayout(new FlowLayout(FlowLayout.LEFT));JPanel jp1 = new JPanel();jp1.add(new JLabel("请输入姓名"));JTextField jtext1 = new JTextField(5);jp1.add(jtext1);JButton jb1 = new JButton("按姓名查找");jp1.add(jb1);jp1.setLayout(new FlowLayout(FlowLayout.LEFT));JPanel jp2 = new JPanel();JButton jb2=new JButton("修改、删除");jp2.add(jb2);jp2.setLayout(new FlowLayout(FlowLayout.LEFT)); JPanel jp3 = new JPanel();jp3.add(new JLabel("浏览职工信息,总人数:"));JButton jb3=new JButton("查看");jp3.add(jb3);jp3.setLayout(new FlowLayout(FlowLayout.LEFT)); //        // 创建一个 10 行 20 列的文本区域final JTextArea textArea = new JTextArea(15,30);// 设置自动换行textArea.setLineWrap(true);JScrollPane jsp4 = new JScrollPane(textArea,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);// 添加到内容面板
//        jp4.add(textArea);//        //创建目标文件对象
//        targetFile = new File(TARGET_FILE);
//        if(targetFile.createNewFile()) {
//            System.out.println("文件不存在,创建成功");
//        }else {
//            System.out.println("文件存在");
//        }//	按ID查找jb0.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("按ID查找");//获取文本显示区文本String[][] res = new String[2][2]; res[0][0] = "ID:";res[0][1] = jtext0.getText();res[1][0] = "姓名:";res[1][1] = jtext1.getText();// 读  FileReader in = null;try {in = new FileReader("temp.txt");} catch (FileNotFoundException e2) {// TODO Auto-generated catch blocke2.printStackTrace();}  BufferedReader bufIn = new BufferedReader(in);  String line = null;  String[] datas = new String[100];//读入结果StringBuffer my_result = new StringBuffer();int i=0;int j=0;try {while ( (line = bufIn.readLine()) != null) {  datas[i]=line;i++;}} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}  while(true) {      	if(datas[j].equals(res[0][0]+res[0][1])) {for(int k=0;k<5;k++) {my_result.append(datas[j]);// 添加换行符  my_result.append(System.getProperty("line.separator"));  j++;}break;}j++;if(datas[j]==null) {System.out.println("抱歉,ID未找到!");break;}}// 关闭 输入流  try {bufIn.close();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}  try {in.close();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}//	更新文本显示区内容textArea.setFont(new Font("宋体", Font.BOLD, 15));textArea.setText(my_result.toString());//	清除框内输入字符jtext0.setText("");}});//	按姓名查找jb1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("按姓名查找");//获取文本显示区文本String[][] res = new String[2][2]; res[0][0] = "ID:";res[0][1] = jtext0.getText();res[1][0] = "姓名:";res[1][1] = jtext1.getText();// 读  FileReader in = null;try {in = new FileReader("temp.txt");} catch (FileNotFoundException e2) {// TODO Auto-generated catch blocke2.printStackTrace();}  BufferedReader bufIn = new BufferedReader(in);  String line = null;  String[] datas = new String[100];//	读入结果StringBuffer my_result = new StringBuffer();int i=0;int j=0;try {while ( (line = bufIn.readLine()) != null) {  datas[i]=line;i++;}} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}while(true) {      	if(datas[j].equals(res[1][0]+res[1][1])) {for(int k=0;k<5;k++) {my_result.append(datas[j-1]);// 添加换行符  my_result.append(System.getProperty("line.separator"));  j++;}break;}j++;if(datas[j]==null) {System.out.println("抱歉,姓名未找到!");break;}}// 关闭 输入流  try {bufIn.close();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}  try {in.close();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}//	更新文本显示区内容textArea.setFont(new Font("宋体", Font.BOLD, 15));textArea.setText(my_result.toString());//  清除框内输入字符jtext1.setText("");}});//	读出到文本区域事件jb3.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("查看->读出到文本区域事件");try {//	字符读入流FileReader reader = new FileReader(targetFile); //	读入缓冲区char[] buffer = new char[1024];//	读入结果StringBuffer result = new StringBuffer();//	每次读入缓冲区的长度int len;//	从读入流中读取文件内容并形成结果while((len = reader.read(buffer)) != -1) {result.append(buffer,0,len);} //	关闭读入流reader.close();//	更新文本显示区内容textArea.setFont(new Font("宋体", Font.BOLD, 15));textArea.setText(result.toString());} catch (FileNotFoundException e1) {// TODO Auto-generated catch blocke1.printStackTrace();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}});//	修改、删除事件jb2.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {change();}});// 创建一个垂直盒子容器, 把上面 JPanel 串起来作为内容面板添加到窗口Box vBox = Box.createVerticalBox();vBox.add(jp0);vBox.add(jp1);vBox.add(jp2);vBox.add(jp3);vBox.add(jsp4);jf.setContentPane(vBox);jf.pack();jf.setLocationRelativeTo(null);jf.setVisible(true);}//	修改、删除 -> 窗口public void change() {JFrame jf = new JFrame("修改、删除职工信息");jf.setSize(300, 300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);// 第 1 个 JPanel, 使用默认的浮动布局JPanel jp0 = new JPanel();jp0.add(new JLabel("ID:"));JTextField jtext0 = new JTextField(10);jp0.add(jtext0);JPanel jp1 = new JPanel();jp1.add(new JLabel("姓名:"));JTextField jtext1 = new JTextField(10);jp1.add(jtext1);JPanel jp2 = new JPanel();jp2.add(new JLabel("出生年月:"));JTextField jtext2 = new JTextField(10);jp2.add(jtext2);JPanel jp3 = new JPanel();jp3.add(new JLabel("工资:"));JTextField jtext3 = new JTextField(10);jp3.add(jtext3);JPanel jp4 = new JPanel();jp4.add(new JLabel("Email:"));JTextField jtext4 = new JTextField(10);jp4.add(jtext4);JPanel jp5 = new JPanel();JButton jb51=new JButton("确认修改");jp5.add(jb51);JButton jb52=new JButton("确认删除");jp5.add(jb52);//	修改事件jb51.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("确认修改");//获取文本显示区文本String[][] result = new String[5][2]; result[0][0] = "ID:";result[0][1] = jtext0.getText();result[1][0] = "姓名:";result[1][1] = jtext1.getText();result[2][0] = "出生年月:";result[2][1] = jtext2.getText();result[3][0] = "工资:";result[3][1] = jtext3.getText();result[4][0] = "Email:";result[4][1] = jtext4.getText();   int found = 0;String[] datas = new String[100];FileReader fileReader;try {fileReader = new FileReader("temp.txt");try (BufferedReader buf = new BufferedReader(fileReader)) {String line = null;int i=0;int j=0;
//						System.out.println("1");while((line = buf.readLine() )!= null){datas[i]=line;i++;}
//						System.out.println("2");while(true) {      	if(datas[j].equals(result[0][0]+result[0][1])) {for(int k=0;k<5;k++) {replacTextContent(datas[j],result[k][0]+result[k][1],j);j++;}found = 1;break;}j++;if(datas[j]==null) {JOptionPane.showMessageDialog(jf,"未找到!","警告",JOptionPane.WARNING_MESSAGE);break;}}
//				        System.out.println("3");// 消息对话框无返回, 仅做通知作用if(found == 1) {JOptionPane.showMessageDialog(jf,"修改成功!","修改",JOptionPane.INFORMATION_MESSAGE);}}} catch (FileNotFoundException e1) {// TODO Auto-generated catch blocke1.printStackTrace();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}//	修改操作   ->		指定行替换txt文件的内容public void replacTextContent(String oldstr, String newStr, int j) throws IOException{//原有的内容String srcStr = oldstr;        //要替换的内容String replaceStr = newStr;     // 读  FileReader in = new FileReader("temp.txt");  BufferedReader bufIn = new BufferedReader(in);  // 内存流, 作为临时流  CharArrayWriter  tempStream = new CharArrayWriter();  // 替换  String line = null;  int i=0;while ( (line = bufIn.readLine()) != null) {  if(i==j) {// 替换每行中, 符合条件的字符串  line = line.replaceAll(srcStr, replaceStr);  }// 将该行写入内存  tempStream.write(line);  // 添加换行符  tempStream.append(System.getProperty("line.separator"));  i++;}  // 关闭 输入流  bufIn.close();  // 将内存中的流 写入 文件  FileWriter out = new FileWriter("temp.txt");  tempStream.writeTo(out);  out.close();  }});//	删除事件jb52.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.out.println("确认删除");//获取文本显示区文本String[][] result = new String[5][2]; result[0][0] = "ID:";result[0][1] = jtext0.getText();result[1][0] = "姓名:";result[1][1] = jtext1.getText();result[2][0] = "出生年月:";result[2][1] = jtext2.getText();result[3][0] = "工资:";result[3][1] = jtext3.getText();result[4][0] = "Email:";result[4][1] = jtext4.getText();   int found = 0;String[] datas = new String[100];FileReader fileReader;try {fileReader = new FileReader("temp.txt");try (BufferedReader buf = new BufferedReader(fileReader)) {String line = null;int i=0;int j=0;
//						System.out.println("1");while((line = buf.readLine() )!= null){datas[i]=line;i++;}
//						System.out.println("2");while(true) {      	if(datas[j].equals(result[0][0]+result[0][1])) {for(int k=0;k<6;k++) {DeleteTextContent(datas[j-1],j-1);j++;}found = 1;break;}j++;if(datas[j]==null) {JOptionPane.showMessageDialog(jf,"未找到!","警告",JOptionPane.WARNING_MESSAGE);break;}}DeleteText2();
//				        System.out.println("3");if(found == 1) {// 消息对话框无返回, 仅做通知作用JOptionPane.showMessageDialog(jf,"删除成功!","删除",JOptionPane.INFORMATION_MESSAGE);}}} catch (FileNotFoundException e1) {// TODO Auto-generated catch blocke1.printStackTrace();} catch (IOException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}}//	删除操作   ->	指定行删除txt文件的内容,	但还有空行public void DeleteTextContent(String oldstr, int j) throws IOException{//原有的内容String srcStr = oldstr;          // 读  FileReader in = new FileReader("temp.txt");  BufferedReader bufIn = new BufferedReader(in);  // 内存流, 作为临时流  CharArrayWriter  tempStream = new CharArrayWriter();  // 替换  String line = null;  int i=0;while ( (line = bufIn.readLine()) != null) {  if(i==j) {// 替换每行中, 符合条件的字符串  line = line.replaceAll(srcStr, "");  }// 将该行写入内存  tempStream.write(line);  // 添加换行符  tempStream.append(System.getProperty("line.separator"));  i++;}  // 关闭 输入流  bufIn.close();  // 将内存中的流 写入 文件  FileWriter out = new FileWriter("temp.txt");  tempStream.writeTo(out);  out.close();  }public void DeleteText2() throws IOException{       // 读  FileReader in = new FileReader("temp.txt");  BufferedReader bufIn = new BufferedReader(in);  // 内存流, 作为临时流  CharArrayWriter  tempStream = new CharArrayWriter();  // 替换  String line = null;  while ( (line = bufIn.readLine()) != null) {  if(line.equals("")) {continue;}else{// 将该行写入内存  tempStream.write(line);  // 添加换行符  tempStream.append(System.getProperty("line.separator"));  }}  // 关闭 输入流  bufIn.close();  // 将内存中的流 写入 文件  FileWriter out = new FileWriter("temp.txt");  tempStream.writeTo(out);  out.close();  }});// 创建一个垂直盒子容器, 把上面 JPanel 串起来作为内容面板添加到窗口Box vBox = Box.createVerticalBox();vBox.add(jp0);vBox.add(jp1);vBox.add(jp2);vBox.add(jp3);vBox.add(jp4);vBox.add(jp5);// 设置窗口的内容面板jf.setContentPane(vBox);//  自动排版
//        jf.pack();/*** 设置窗口的相对位置。* 如果 comp 整个显示区域在屏幕内, 则将窗口放置到 comp 的中心;* 如果 comp 显示区域有部分不在屏幕内, 则将该窗口放置在最接近 comp 中心的一侧;* comp 为 null, 表示将窗口放置到屏幕中心。*/jf.setLocationRelativeTo(null);// 设置窗口是否可见jf.setVisible(true);}public static void main(String[] args) {new Test();}}

这篇关于JAVA_GUI之“职工信息管理系统”的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/439002

相关文章

springboot的调度服务与异步服务使用详解

《springboot的调度服务与异步服务使用详解》本文主要介绍了Java的ScheduledExecutorService接口和SpringBoot中如何使用调度线程池,包括核心参数、创建方式、自定... 目录1.调度服务1.1.JDK之ScheduledExecutorService1.2.spring

将java程序打包成可执行文件的实现方式

《将java程序打包成可执行文件的实现方式》本文介绍了将Java程序打包成可执行文件的三种方法:手动打包(将编译后的代码及JRE运行环境一起打包),使用第三方打包工具(如Launch4j)和JDK自带... 目录1.问题提出2.如何将Java程序打包成可执行文件2.1将编译后的代码及jre运行环境一起打包2

Java使用Tesseract-OCR实战教程

《Java使用Tesseract-OCR实战教程》本文介绍了如何在Java中使用Tesseract-OCR进行文本提取,包括Tesseract-OCR的安装、中文训练库的配置、依赖库的引入以及具体的代... 目录Java使用Tesseract-OCRTesseract-OCR安装配置中文训练库引入依赖代码实

Java中对象的创建和销毁过程详析

《Java中对象的创建和销毁过程详析》:本文主要介绍Java中对象的创建和销毁过程,对象的创建过程包括类加载检查、内存分配、初始化零值内存、设置对象头和执行init方法,对象的销毁过程由垃圾回收机... 目录前言对象的创建过程1. 类加载检查2China编程. 分配内存3. 初始化零值4. 设置对象头5. 执行

SpringBoot整合easy-es的详细过程

《SpringBoot整合easy-es的详细过程》本文介绍了EasyES,一个基于Elasticsearch的ORM框架,旨在简化开发流程并提高效率,EasyES支持SpringBoot框架,并提供... 目录一、easy-es简介二、实现基于Spring Boot框架的应用程序代码1.添加相关依赖2.添

通俗易懂的Java常见限流算法具体实现

《通俗易懂的Java常见限流算法具体实现》:本文主要介绍Java常见限流算法具体实现的相关资料,包括漏桶算法、令牌桶算法、Nginx限流和Redis+Lua限流的实现原理和具体步骤,并比较了它们的... 目录一、漏桶算法1.漏桶算法的思想和原理2.具体实现二、令牌桶算法1.令牌桶算法流程:2.具体实现2.1

SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程

《SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程》本文详细介绍了如何在虚拟机和宝塔面板中安装RabbitMQ,并使用Java代码实现消息的发送和接收,通过异步通讯,可以优化... 目录一、RabbitMQ安装二、启动RabbitMQ三、javascript编写Java代码1、引入

spring-boot-starter-thymeleaf加载外部html文件方式

《spring-boot-starter-thymeleaf加载外部html文件方式》本文介绍了在SpringMVC中使用Thymeleaf模板引擎加载外部HTML文件的方法,以及在SpringBoo... 目录1.Thymeleaf介绍2.springboot使用thymeleaf2.1.引入spring

Java实现检查多个时间段是否有重合

《Java实现检查多个时间段是否有重合》这篇文章主要为大家详细介绍了如何使用Java实现检查多个时间段是否有重合,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录流程概述步骤详解China编程步骤1:定义时间段类步骤2:添加时间段步骤3:检查时间段是否有重合步骤4:输出结果示例代码结语作

Java中String字符串使用避坑指南

《Java中String字符串使用避坑指南》Java中的String字符串是我们日常编程中用得最多的类之一,看似简单的String使用,却隐藏着不少“坑”,如果不注意,可能会导致性能问题、意外的错误容... 目录8个避坑点如下:1. 字符串的不可变性:每次修改都创建新对象2. 使用 == 比较字符串,陷阱满