Java
文章平均质量分 67
好好活着,不要熬夜
这个作者很懒,什么都没留下…
展开
-
Java - TCP 通信
【代码】Java - TCP tong。原创 2022-12-31 12:00:39 · 231 阅读 · 1 评论 -
Java - 使用递归求一个数的阶乘
Java 代码:运行程序,控制台输出:参考百度百科 - 阶乘原创 2022-07-13 12:54:44 · 586 阅读 · 0 评论 -
Java - 列出文件夹中的文件(使用递归)
使用 tree 命令查看我将要列出的文件夹中的文件:Java 代码:运行程序,控制台输出:原创 2022-07-11 12:52:09 · 483 阅读 · 0 评论 -
Java - LocalDateTime 格式化输出日期字符串
文章目录示例参考示例package com.mk.test;import java.time.LocalDateTime;import java.time.format.DateTimeFormatter;public class Test { public static void main(String[] args) { String pattern = "yyyy.MM.dd HH:mm:ss"; DateTimeFormatter dateTi原创 2022-04-17 20:10:17 · 3876 阅读 · 0 评论 -
Ubuntu 18.04 - 下载、配置 Maven
文章目录Ubuntu - 下载、配置 Maven环境信息下载 Maven 并解压计算文件的校验和解压文件在 Spring Tool Suite 4 中配置 MavenUbuntu - 下载、配置 Maven环境信息Ubuntu 系统信息:$ lsb_release --allNo LSB modules are available.Distributor ID: UbuntuDesc...原创 2020-02-08 15:53:45 · 1626 阅读 · 0 评论 -
Ubuntu 20.04 - 查找 JDK 的安装位置
文章目录查找 JDK 的安装位置方法 1方法 2参考Ubuntu 版本信息:$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 20.04.3 LTSRelease: 20.04Codename: focal查找 JDK 的安装位置Java 版本信息:$ java -versionopenjdk version "1.8.0_312"OpenJDK Runtim原创 2022-02-18 17:39:25 · 10146 阅读 · 0 评论 -
Ubuntu 20.04 - 安装 OpenJDK 8
文章目录$ lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription: Ubuntu 20.04.3 LTSRelease: 20.04Codename: focal$ java -versionCommand 'java' not found, but can be installed with:sudo apt install default-jre # ve原创 2022-02-18 15:13:54 · 10303 阅读 · 0 评论 -
Java Servlet Technology - 网页重定向
文章目录Redirections in HTTP302 FoundLocation实践环境新建项目使用 `HttpServletResponse.sendRedirect(String)` 进行重定向测试使用状态码和响应头进行重定向测试参考Redirections in HTTPURL redirection, also known as URL forwarding, is a technique to give more than one URL address to a page, a form,原创 2021-12-25 13:09:44 · 406 阅读 · 0 评论 -
Java Servlet Technology - 上传文件
文章目录Java Servlet TechnologyUploading Files with Java Servlet TechnologyThe @MultipartConfig AnnotationThe getParts and getPart Methods实践环境新建项目上传单个文件基于表单上传单个文件测试基于 AJAX 上传单个文件测试上传多个文件基于表单上传多个文件测试基于 AJAX 上传多个文件测试参考Java Servlet TechnologyUploading Files wit原创 2021-12-24 11:38:09 · 431 阅读 · 0 评论 -
Java Servlet - 获取请求头
文章目录Writing Service Methods实践环境新建项目获取请求头测试使用火狐浏览器测试使用谷歌浏览器测试参考Writing Service MethodsThe service provided by a servlet is implemented in the service method of a GenericServlet, in the doMethod methods (where Method can take the value Get, Delete, Options原创 2021-12-23 12:20:46 · 1790 阅读 · 0 评论 -
Java Servlet - 服务器响应数据给客户端
文章目录Writing Service MethodsConstructing Responses实践环境新建项目服务器响应字符串数据流测试服务器响应 JSON 数据流测试服务器响应图片流测试服务器响应 PDF 文件流测试参考Writing Service MethodsConstructing ResponsesA response contains data passed between a server and the client. All responses implement the Se原创 2021-12-22 18:02:02 · 1617 阅读 · 0 评论 -
Java Servlet - 从请求中获取用户提交的参数
文章目录Writing Service MethodsGetting Information from Requests实践环境新建项目从 GET 请求中获取用户提交的参数测试从 POST 请求中获取用户提交的参数测试参考Writing Service MethodsGetting Information from RequestsA request contains data passed between a client and the servlet. All requests implemen原创 2021-12-22 11:44:24 · 1539 阅读 · 0 评论 -
Java Servlet - 获取服务器名称、端口,客户端地址、端口等信息
文章目录Writing Service MethodsGetting Information from Requests实践环境新建项目测试参考Writing Service MethodsGetting Information from RequestsA request contains data passed between a client and the servlet. All requests implement the ServletRequest interface. This in原创 2021-12-21 15:46:50 · 4012 阅读 · 1 评论 -
Java Servlet - Servlet 生命周期
文章目录Servlet 生命周期实践环境新建项目编写 Servlet启动服务器测试参考Servlet 生命周期The lifecycle of a servlet is controlled by the container in which the servlet has been deployed. When a request is mapped to a servlet, the container performs the following steps.servlet 的生命周期由部署 s原创 2021-12-19 18:18:37 · 692 阅读 · 0 评论 -
Java - 屏幕截图
package com.mk;import java.awt.AWTException;import java.awt.Dimension;import java.awt.Rectangle;import java.awt.Robot;import java.awt.Toolkit;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import java.text.Date原创 2021-12-11 20:15:08 · 90 阅读 · 0 评论 -
Java - 读取系统属性(System Properties)
文章目录示例参考示例代码:public class Main { public static void main(String[] args) { String javaHome = System.getProperty("java.home"); String javaVendor = System.getProperty("java.vendor"); String javaVendorUrl = System.getProperty("j原创 2021-12-07 09:53:32 · 1375 阅读 · 0 评论 -
在 Spring Tool Suite (STS) 中安装 Lombok
文章目录检查 STS 是否已经安装 Lombok下载 Lombok安装 Lombok验证参考操作系统:Windows 10 x64检查 STS 是否已经安装 Lombok启动 STS,选择主菜单 Help > About Spring Tool Suite 4 查看 STS 的版本信息。如果已经安装过 Lombok,那么这里也会列出关于 Lombok 的版本信息,像我的是没有的:下载 Lombok访问 https://projectlombok.org/download,下载 Lombok原创 2021-12-05 17:47:10 · 2475 阅读 · 0 评论 -
The Java™ Tutorials
ObjectsCreating Objects原创 2021-09-17 08:32:25 · 130 阅读 · 0 评论 -
The Java™ Tutorials > Learning the Java Language > Classes and Objects > Objects > Creating Objects
Creating Objects 创建对象As you know, a class provides the blueprint for objects; you create an object from a class. Each of the following statements taken from the CreateObjectDemo program creates an object and assigns it to a variable:如你所知,类为对象提供蓝图;您从类创建对象翻译 2021-09-04 19:27:37 · 116 阅读 · 0 评论 -
The Java™ Tutorials > Learning the Java Language > Classes and Objects > Objects
Objects 对象A typical Java program creates many objects, which as you know, interact by invoking methods. Through these object interactions, a program can carry out various tasks, such as implementing a GUI, running an animation, or sending and receiving in翻译 2021-09-04 09:55:46 · 100 阅读 · 0 评论 -
Classes and Objects > Classes > Passing Information to a Method or a Constructor
Passing Information to a Method or a ConstructorThe declaration for a method or a constructor declares the number and the type of the arguments for that method or constructor. For example, the following is a method that computes the monthly payments for a翻译 2021-09-01 23:00:13 · 173 阅读 · 0 评论 -
使用 Editor.md 图片上传出现的问题及解决思路
文章目录Spring Boot - 使用 Editor.md 图片上传出现的问题问题及解决思路参考Spring Boot - 使用 Editor.md 图片上传出现的问题Spring Boot 2.2.4.RELEASE问题及解决思路须知:项目是前后端分离,涉及跨域。测试使用的是 Editor.md 提供的示例“image-upload.html”,该文件位于 examples 文件夹。...原创 2020-02-06 12:12:09 · 7322 阅读 · 24 评论 -
Classes and Objects > Classes > Providing Constructors for Your Classes
Providing Constructors for Your ClassesA class contains constructors that are invoked to create objects from the class blueprint. Constructor declarations look like method declarations—except that they use the name of the class and have no return type. Fo翻译 2021-09-01 22:45:21 · 64 阅读 · 0 评论 -
The Java™ Tutorials > Learning the Java Language > Classes and Objects > Classes > Defining Methods
Defining MethodsHere is an example of a typical method declaration:public double calculateAnswer(double wingSpan, int numberOfEngines, double length, double grossTons) { //do the calculation here}The only required ele翻译 2021-09-01 22:41:47 · 77 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Classes and Objects - Declaring Member Variables
Declaring Member Variables 声明成员变量There are several kinds of variables: 有几种变量:Member variables in a class—these are called fields. 类中的成员变量 —— 这些称为字段。Variables in a method or block of code—these are called local variables. 方法或代码块中的变量称为局部变量。Variables in翻译 2021-09-01 09:22:16 · 104 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Classes and Objects - Classes - Declaring Classes
Declaring ClassesYou’ve seen classes defined in the following way:class MyClass { // field, constructor, and // method declarations}This is a class declaration. The class body (the area between the braces) contains all the code that provides翻译 2021-08-31 22:53:09 · 81 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Classes and Objects - Classes
Classes 类The introduction to object-oriented concepts in the lesson titled Object-oriented Programming Concepts used a bicycle class as an example, with racing bikes, mountain bikes, and tandem bikes as subclasses. Here is sample code for a possible imple翻译 2021-08-31 22:50:51 · 88 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Summary of Creating and Using Classes and Objects
Summary of Creating and Using Classes and ObjectsA class declaration names the class and encloses the class body between braces. The class name can be preceded by modifiers. The class body contains fields, methods, and constructors for the class. A class翻译 2021-08-31 16:49:58 · 84 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Initializing Fields
Initializing Fields 初始化字段As you have seen, you can often provide an initial value for a field in its declaration:正如你所看到的,你通常可以在一个字段的声明中提供一个初始值:public class BedAndBreakfast { // initialize to 10 public static int capacity = 10; // initializ翻译 2021-08-31 16:46:44 · 86 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Understanding Class Members
Understanding Class Members 理解类成员In this section, we discuss the use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class.在本节中,我们将讨论如何使用 static 关键字创建属于类而不是类实例的字段和方法。Class Variables 类变量When翻译 2021-08-31 11:51:44 · 142 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Controlling Access to Members of a Class
Controlling Access to Members of a ClassAccess level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:访问级别修饰符决定其他类是否可以使用某个特定的字段或调用某个特定的方法。有两种访问控制级别:At the top lev翻译 2021-08-30 19:30:12 · 94 阅读 · 0 评论 -
The Java™ Tutorials - Learning the Java Language - Using the this Keyword
Using the this KeywordWithin an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a con翻译 2021-08-30 17:35:09 · 97 阅读 · 0 评论 -
Java - 模拟生成上、下班打卡数据
package com.mk.test;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.GregorianCalendar;import java.util.Random;public class Test2 { public static void main(String[] args) { DateFo原创 2021-07-23 06:13:52 · 846 阅读 · 0 评论 -
Log4j-1.2.17 记录异常信息
操作系统:Windows 10 x64IDE:Spring Tool Suite 4, Version: 4.4.0.RELEASE, Build Id: 201909171436Maven 项目,结构:pom.xml 文件:<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.or...原创 2019-12-18 21:56:05 · 887 阅读 · 0 评论 -
MyBatis 使用 Log4j 实现日志输出
操作系统:Windows 10 x64IDE:Spring Tool Suite 4, Version: 4.4.0.RELEASE, Build Id: 201909171436MyBatis:3.5.3Log4j:1.2.17日志的配置思路1、在 MyBatis 的配置文件中指定使用某种日志。2、导入相关的 jar 包或引入相关的依赖。3、配置 log4j.properties...原创 2019-12-19 11:29:08 · 1561 阅读 · 0 评论 -
解决 Swagger 被 Shiro 拦截的思路
解决 Swagger 被 Shiro 拦截的思路异常现象注意:该项目使用的不是 Swagger 原生的 UI,而是一个第三方的中文 UI。参考:https://github.com/xiaoymin/swagger-bootstrap-ui异常现象在 application.yml 文件中,Shiro 已经允许匿名访问 /doc.html* 和 /webjars/**:访问 http:...原创 2019-12-13 19:09:34 · 2821 阅读 · 0 评论 -
OpenPDF
示例APIGitHub原创 2020-01-05 22:56:32 · 3322 阅读 · 0 评论 -
JSR356
JSR356原创 2021-03-17 13:16:36 · 187 阅读 · 0 评论 -
Spring Boot - PDF 预览(非前后端分离)
文章目录项目参考集成开发环境:Spring Tool Suite 4 - Version: 4.4.0.RELEASE测试环境:Google Chrome - Version 88.0.4324.104 (Official Build) (64-bit)项目效果新建 Spring Starter Project,项目结构:编辑 pom.xml 文件,引入依赖:<?xml version="1.0" encoding="UTF-8"?><project xmlns="ht原创 2021-03-16 22:45:52 · 1001 阅读 · 0 评论 -
Java - 基于 Apache POI 操作(创建或读取) Excel 文件
新建 Maven Project,引入依赖:<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version></dependency>示例:import java.io.File;import java.io.IOException;imp原创 2021-01-16 14:57:37 · 468 阅读 · 1 评论