欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring MVC+FastJson+hibernate-validator整合的完整實例教程

 更新時間:2018年04月28日 10:58:26   作者:vbirdbest  
這篇文章主要給大家介紹了關于Spring MVC+FastJson+hibernate-validator整合的完整實例教程,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧。

一:hibernate-validator 基礎

1. 簡介:

通過使用注解Annotations 給類或者類的屬性加上約束(constraint),在運行期檢查屬性值的合法性.

2. 作用:

在API接口開發(fā)中參數(shù)校驗是非常重要的事情,因為客戶端很可能會少傳參數(shù),或者值不合法,甚至參數(shù)值是惡意的,所以對客戶端傳來的參數(shù)的合法性就必須要校驗了,其中將參數(shù)值的校驗規(guī)則通過注解的形式注解到屬性上是一種比較優(yōu)雅的方式。

3. 常用的約束注解

  • @Null 被注釋的元素必須為 null
  • @NotNull 被注釋的元素必須不為 null
  • @AssertTrue 被注釋的元素必須為 true
  • @AssertFalse 被注釋的元素必須為 false
  • @Min(value) 被注釋的元素必須是一個數(shù)字,其值必須大于等于指定的最小值
  • @Max(value) 被注釋的元素必須是一個數(shù)字,其值必須小于等于指定的最大值
  • @DecimalMin(value) 被注釋的元素必須是一個數(shù)字,其值必須大于等于指定的最小值
  • @DecimalMax(value) 被注釋的元素必須是一個數(shù)字,其值必須小于等于指定的最大值
  • @Size(max=, min=) 被注釋的元素的大小必須在指定的范圍內(nèi)
  • @Digits (integer, fraction) 被注釋的元素必須是一個數(shù)字,其值必須在可接受的范圍內(nèi)
  • @Past 被注釋的元素必須是一個過去的日期
  • @Future 被注釋的元素必須是一個將來的日期
  • @Pattern(regex=,flag=) 被注釋的元素必須符合指定的正則表達式
  • Hibernate Validator 附加的 constraint
  • @NotBlank(message =) 驗證字符串非null,且長度必須大于0
  • @Email 被注釋的元素必須是電子郵箱地址
  • @Length(min=,max=) 被注釋的字符串的大小必須在指定的范圍內(nèi)
  • @NotEmpty 被注釋的字符串的必須非空
  • @Range(min=,max=,message=) 被注釋的元素必須在合適的范圍內(nèi)
  • @URL(protocol=,host=, port=, regexp=, flags=) 被注釋的字符串必須是一個有效的url
  • @CreditCardNumber 被注釋的字符串必須通過Luhn校驗算法,銀行卡,信用卡等號碼一般都用Luhn計算合法性
  • @ScriptAssert(lang=, script=, alias=) 要有Java Scripting API 即JSR 223 (“Scripting for the JavaTM Platform”)的實現(xiàn)
  • @SafeHtml(whitelistType=, additionalTags=) classpath中要有jsoup包

4. 初識hibernate-validator

public class Address {
 @NotNull private String line1;
 private String line2;
 private String zip;
 private String state;
 @Length(max = 20)
 @NotNull
 private String country;
 @Range(min = -2, max = 50, message = "Floor out of range")
 public int floor;
 // getter&&setter
}

二:整合校驗 hibernate-validator

該示例是在SpringMVC+FastJson整合(http://www.dbjr.com.cn/article/139094.htm)基礎上進行集成的,可以先看一下這篇文章(有源碼供下載),在該文章的基礎上整合hibernate-validator

整合步驟:

1、在pom.xml中引入hibernate-validator依賴

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
 <version>5.4.1.Final</version>
</dependency>

2、在[xxx]-servlet.xml中配置驗證器:HibernateValidator

<!-- <mvc:annotation-driven> 增加驗證器屬性validator="validator" -->
<mvc:annotation-driven validator="validator">
 <mvc:message-converters register-defaults="true">
 <!-- 配置Fastjson 替換原來的jackson支持 -->
 <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
 <property name="supportedMediaTypes">
  <list>
  <value>text/html;charset=UTF-8</value>
  <value>application/json</value>
  </list>
 </property>
 <property name="features">
  <list>
  <value>QuoteFieldNames</value> 
  <value>WriteMapNullValue</value> 
  </list>
 </property>
 </bean>
 </mvc:message-converters>
 </mvc:annotation-driven>

 <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
 <property name="providerClass" value="org.hibernate.validator.HibernateValidator"/> 
 <property name="validationMessageSource" ref="messageSource"/> 
 </bean>

 <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
 <property name="basenames"> 
 <list> 
 <value>classpath:conf/settings/validation</value> 
 <value>classpath:org/hibernate/validator/ValidationMessages</value> 
 </list> 
 </property> 
 <property name="useCodeAsDefaultMessage" value="false"/> 
 <property name="defaultEncoding" value="UTF-8"/> 
 <property name="cacheSeconds" value="60"/> 
 </bean>

3、在src/main/resources/conf/settings位置定義驗證消息文件描述 validation.properties

validation.common.not.null=該字段不能為空
validation.common.not.range=長度非法
validation.common.format.error=格式錯誤

validation.param.age=年齡未滿18周歲

rep.error.unknown=未知錯誤

4、新建實體類以供測試

UserEntity

package com.mengdee.manage.validator;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
public class UserEntity {
 @Null(groups={GroupA.class})
 @NotNull(groups={GroupB.class})
 @Min(value = 1, message="id值必須大于0", groups={GroupB.class})
 private Long id;

 @NotBlank(groups={GroupA.class, GroupB.class})
 @Pattern(regexp="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$", message="由6-21字母和數(shù)字組成,不能是純數(shù)字或純英文", groups={GroupA.class, GroupB.class})
 private String password;

 @NotBlank(groups={GroupA.class, GroupB.class})
 @Pattern(regexp="^((13[0-9])|(15[^4,\\D])|(18[0,3-9]))\\d{8}$", message="手機號格式不正確")
 private String phone;


 @NotBlank(groups={GroupB.class})
 @Length(min=6, max=12, message="昵稱長度為6到12位")
 private String nickname;

 @Min(value=18, message="{validation.param.age}")
 private int age;

 @NotBlank(groups={GroupA.class})
 @Email(message="{validation.common.format.error}")
 private String email;

 @NotBlank
 @Length(min=3, max=10, message="{validation.common.not.range}")
 private String username;


 public UserEntity() {

 }


 public Long getId() {
 return id;
 }

 public void setId(Long id) {
 this.id = id;
 }

 public String getNickname() {
 return nickname;
 }

 public void setNickname(String nickname) {
 this.nickname = nickname;
 }

 public int getAge() {
 return age;
 }

 public void setAge(int age) {
 this.age = age;
 }

 public String getEmail() {
 return email;
 }

 public void setEmail(String email) {
 this.email = email;
 }

 public String getPassword() {
 return password;
 }

 public void setPassword(String password) {
 this.password = password;
 }

 public String getUsername() {
 return username;
 }

 public void setUsername(String username) {
 this.username = username;
 }

 public String getPhone() {
 return phone;
 }

 public void setPhone(String phone) {
 this.phone = phone;
 }
}

UserModel

package com.mengdee.manage.validator;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
public class UserModel {
 @Min(value = 1, message="id值必須大于0")
 private long id;

 @NotBlank
 @Length(min=6, max=12, message="昵稱長度為6到12位")
 private String nickname;

 @Min(value=18, message="{validation.param.age}")
 private int age;

 @NotBlank
 @Email(message="{validation.common.format.error}")
 private String email;

 @NotBlank
 @Pattern(regexp="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$", message="由6-21字母和數(shù)字組成,不能是純數(shù)字或純英文")
 private String password;

 @NotBlank
 @Length(min=3, max=10, message="{validation.common.not.range}")
 private String username;

 @NotBlank
 @Pattern(regexp="^((13[0-9])|(15[^4,\\D])|(18[0,3-9]))\\d{8}$", message="手機號格式不正確")
 private String phone;


 public UserModel() {

 }


 public long getId() {
 return id;
 }

 public void setId(long id) {
 this.id = id;
 }

 public String getNickname() {
 return nickname;
 }

 public void setNickname(String nickname) {
 this.nickname = nickname;
 }

 public int getAge() {
 return age;
 }

 public void setAge(int age) {
 this.age = age;
 }

 public String getEmail() {
 return email;
 }

 public void setEmail(String email) {
 this.email = email;
 }

 public String getPassword() {
 return password;
 }

 public void setPassword(String password) {
 this.password = password;
 }

 public String getUsername() {
 return username;
 }

 public void setUsername(String username) {
 this.username = username;
 }

 public String getPhone() {
 return phone;
 }

 public void setPhone(String phone) {
 this.phone = phone;
 } 
}

UserDetail :

package com.mengdee.manage.validator;
import org.hibernate.validator.constraints.NotBlank;
public class UserDetail {

 private Long id;

 @NotBlank
 private String address;

 @NotBlank
 private String company;



 public UserDetail() {

 }


 public Long getId() {
 return id;
 }
 public void setId(Long id) {
 this.id = id;
 }
 public String getAddress() {
 return address;
 }
 public void setAddress(String address) {
 this.address = address;
 }
 public String getCompany() {
 return company;
 }
 public void setCompany(String company) {
 this.company = company;
 }
}

使用ValidController 進行測試

package com.mengdee.manage.controller;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mengdee.manage.validator.UserModel;

@Controller
@RequestMapping("/Valid")
public class ValidController extends BaseController {

 // http://localhost:8081/platform-springmvc-webapp/Valid/test?age=18&nickname=mengdee&id=1&email=123@qq.com&password=root123&username=123&phone=18321758957
 @RequestMapping(value = "/test", method = RequestMethod.GET)
 public @ResponseBody Object validation(HttpServletRequest request, @Valid UserModel user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return super.ResponseJsonError(fieldError);
 }

 return "ok";
 }


 // 一個方法同時校驗多個對象需要綁定多個結果BindingResult,出現(xiàn)一個@Valid就對應后面聲明的一個BindingResult
 @RequestMapping(value = "/test2", method = RequestMethod.GET)
 public @ResponseBody Object validationMore(HttpServletRequest request, 
 @Valid UserModel user, BindingResult bindingResult,
 @Valid UserDetail userDetail, BindingResult bindingResult2){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return super.ResponseJsonError(fieldError);
 }

 if (bindingResult2.hasErrors()) {
 FieldError fieldError = bindingResult2.getFieldError();

 return super.ResponseJsonError(fieldError);
 }
 return "ok";
 }
}

使用注意:

1、對于多個字段,系統(tǒng)驗證的順序好像和字段聲明的順序是不一樣的,好像是無須的

2、對于每個驗證如果沒有message屬性,系統(tǒng)會使用默認的,如對應@NotBlank相當于@NotBlank(message=”不能為空”)

3、對于引用類型如String等類型,一定要結合@NotNull、@NotEmpty或者@NotBlank來配合使用,如果不寫空的約束,經(jīng)測試,該字段是不參與校驗的,如單獨使用@Pattern、@Length、@Email等是不會進行驗證的,必須要使用空的約束來限制

@Min:用于基本數(shù)據(jù)類型,如int、long等

@NotNull: 任何對象的value不能為null

@NotEmpty:集合對象的元素不為0,即集合不為空,也可以用于字符串不為null

@NotBlank:只能用于字符串不為null,并且字符串trim()以后length要大于0

三:分組校驗@Validated

  • @Valid是屬于javax.validation.Valid里的。
  • @Validated是@Valid 的一次封裝,是spring提供的校驗機制使用(org.springframework.validation.annotation.Validated) ,@Valid不提供分組功能

1. 分組的作用(使用場景):

每個校驗的注解約束都有一個groups屬性,用于指定該約束是屬于哪個組的,這樣在同一個字段上就可以配置多套約束,在使用的時候只需要指定使用那套約束即可,例如對于注冊用戶和修改用戶信息時,注冊時id必須為空,修改用戶信息時id必須不能為空,在使用的時候只需要將這兩種約束分配到不同的組中即可,如添加時使用組A的約束,更新時使用組B的約束

2. 分組就是一個空接口interface

GroupA 和 GroupB

package com.mengdee.manage.validator;
public interface GroupA {
}

package com.mengdee.manage.validator;
public interface GroupB {
}

在使用時指定具體使用那套分組的約束@Validated({GroupA.class})

3. 組序列@GroupSequence

默認情況下,不同組別的約束驗證是無序的,組序列就是按照分組的前后順序依次驗證,如先驗證GroupA組的約束,再驗證GroupB組的約束。如果對組的校驗順序有要求,例如必須先校驗A組再校驗B組,可以使用@GroupSequence來定義每個組的順序

使用場景:

(1)第二個組中的約束驗證依賴于一個穩(wěn)定狀態(tài)來運行,而這個穩(wěn)定狀態(tài)是由第一個組來進行驗證的。

(2)某個組的驗證比較耗時,CPU 和內(nèi)存的使用率相對比較大,最優(yōu)的選擇是將其放在最后進行驗證。因此,在進行組驗證的時候尚需提供一種有序的驗證方式,這就提出了組序列的概念。

一個組可以定義為其他組的序列,使用它進行驗證的時候必須符合該序列規(guī)定的順序。在使用組序列驗證的時候,如果序列前邊的組驗證失敗,則后面的組將不再給予驗證。

使用注解GroupSequence定義組序列:GroupAB

package com.mengdee.manage.validator;
import javax.validation.GroupSequence;
@GroupSequence({GroupA.class, GroupB.class})
public interface GroupAB {

ValidationController

package com.mengdee.manage.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mengdee.manage.validator.GroupA;
import com.mengdee.manage.validator.GroupAB;
import com.mengdee.manage.validator.GroupB;
import com.mengdee.manage.validator.UserEntity;

@Controller
@RequestMapping("/validated")
public class ValidationController extends BaseController {

 // 校驗時指定了GroupA,那么只校驗約束中包含GroupA的約束,沒有包含就不校驗,例如對于phone, @NotBlank指定的分組,而@Pattern沒有指定分組,那么只校驗空著一個約束,不校驗手機號格式
 // http://localhost:8081/platform-springmvc-webapp/validated/groupA?password=root123&phone=123
 @RequestMapping(value = "/groupA", method = RequestMethod.GET)
 public @ResponseBody Object groupA(HttpServletRequest request, @Validated({GroupA.class}) UserEntity user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return this.ResponseJsonError(fieldError);
 }

 return "ok";
 }

 // http://localhost:8081/platform-springmvc-webapp/validated/groupB?phone=123&password=root123&id=1
 @RequestMapping(value = "/groupB", method = RequestMethod.GET)
 public @ResponseBody Object groupB(HttpServletRequest request, @Validated({GroupB.class}) UserEntity user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return this.ResponseJsonError(fieldError);
 }

 return "ok";
 }

 // groupAB
 // http://localhost:8081/platform-springmvc-webapp/validated/groupAB?phone=111&password=root123&nickname=123&email=xxx@qq.com
 // @Validated({GroupA.class, GroupB.class}):GroupA和GroupB的關系是或的關系,就像數(shù)據(jù)庫中的OR一樣,只要滿足一個條件就會對該約束進行校驗,同時使用多個組注意多個組之間沒有先后屬性之說,并不是先校驗組A,然后再校驗組B
 // 因為id的為空和不為空的約束都會進行檢查,所以先注釋掉該屬性
 @RequestMapping(value = "/groupAB", method = RequestMethod.GET)
 public @ResponseBody Object groupAB(HttpServletRequest request, @Validated({GroupA.class, GroupB.class}) UserEntity user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return this.ResponseJsonError(fieldError);
 }

 return "ok";
 }

 // default
 // http://localhost:8081/platform-springmvc-webapp/default?email=xxx@163.com&age=18
 // @Validated 如果沒有指定groups則驗證沒有分組的屬性(此時和@Valid功能一樣),如果一個字段上有多個約束,都必須沒有指定組,如果部分約束指定的組,部分約束沒有指定約束,那么在使用@Validated時不進行檢查的
 @RequestMapping(value = "/default", method = RequestMethod.GET)
 public @ResponseBody Object defaultGroup(HttpServletRequest request, @Validated UserEntity user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return this.ResponseJsonError(fieldError);
 }

 return "ok";
 }

 //localhost:8081/platform-springmvc-webapp/validated/sequence?phone=123&password=root123&email=123&nickname=123
 // 對于一個屬性上有多個約束,并且多個約束不都在同一個組,那么在檢查的時候順序是根據(jù)GroupSequence定義的先后順序來檢查的
 @RequestMapping(value = "/sequence", method = RequestMethod.GET)
 public @ResponseBody Object sequence(HttpServletRequest request, @Validated({GroupAB.class}) UserEntity user, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();

 return this.ResponseJsonError(fieldError);
 }
 return "ok";
 }
}

四:自定義hibernate validation注解

當hibernate validation提供的注解不能滿足需求時,可以自定義校驗約束。

自定義注解約束步驟:

  • 創(chuàng)建注解
  • 創(chuàng)建注解對應的約束驗證類
  • 使用注解
  • 測試注解

創(chuàng)建注解 @Phone

package com.mengdee.manage.validator;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {PhoneConstraint.class})
public @interface Phone {
 String message() default "手機號格式錯誤";
 String regexp() default "^((13[0-9])|(15[^4,\\D])|(18[0,3-9]))\\d{8}$";
 Class<?>[] groups() default {};
 Class<? extends Payload>[] payload() default { };
 @Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
 @Retention(RUNTIME)
 @Documented
 public @interface List {
 Phone[] value();
 } 
}

創(chuàng)建手機號注解對應的約束驗證類PhoneConstraint

package com.mengdee.manage.validator;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class PhoneConstraint implements ConstraintValidator<Phone, String> {
 private String regexp;
 @Override
 public void initialize(Phone phoneAnnotation) {
 this.regexp = phoneAnnotation.regexp();
 }

 @Override
 public boolean isValid(String value, ConstraintValidatorContext context) {
 if (value == null) {
 return true; // HV000028: Unexpected exception during isValid call
 }

 if (value.matches(regexp)) {
 return true;
 }
 return false;
 }
}

在屬性上使用注解@Phone

package com.mengdee.manage.validator;
import org.hibernate.validator.constraints.NotBlank;
public class UserDetail {
 @NotBlank
 @Phone
 private String phone;
 public UserDetail() {

 }

 public String getPhone() {
 return phone;
 }

 public void setPhone(String phone) {
 this.phone = phone;
 }
}

測試注解

// http://localhost:8081/platform-springmvc-webapp/Valid/test3?address=123&company=456&phone=123
 @RequestMapping(value = "/test3", method = RequestMethod.GET)
 public @ResponseBody Object validationCustomAnnotation(HttpServletRequest request, 
 @Valid UserDetail userDetail, BindingResult bindingResult){
 if (bindingResult.hasErrors()) {
 FieldError fieldError = bindingResult.getFieldError();
 return super.ResponseJsonError(fieldError);
 }
 return "ok";
 }

完整代碼下載:http://xiazai.jb51.net/201804/yuanma/platform-springmvc-webapp(jb51.net).rar

總結

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

參考文章:

相關文章

  • Java中鎖的分類與使用方法

    Java中鎖的分類與使用方法

    這篇文章主要給大家介紹了關于Java中鎖分類與使用的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • stream中使用peek一些陷阱避免及解決方法

    stream中使用peek一些陷阱避免及解決方法

    這篇文章主要為大家介紹了stream中使用peek一些陷阱避免及解決方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-03-03
  • 帶你盤點Java的五種運算符

    帶你盤點Java的五種運算符

    這篇文章主要介紹了Java基本數(shù)據(jù)類型和運算符,結合實例形式詳細分析了java基本數(shù)據(jù)類型、數(shù)據(jù)類型轉換、算術運算符、邏輯運算符等相關原理與操作技巧,需要的朋友可以參考下
    2021-07-07
  • IDEA中編寫并運行shell腳本的實現(xiàn)

    IDEA中編寫并運行shell腳本的實現(xiàn)

    這篇文章主要介紹了IDEA中編寫并運行shell腳本的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-08-08
  • 【Java】BigDecimal實現(xiàn)加減乘除運算代碼

    【Java】BigDecimal實現(xiàn)加減乘除運算代碼

    本篇文章主要介紹了【Java】BigDecimal實現(xiàn)加減乘除運算代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-02-02
  • Java Swing編寫一個簡單的計算器軟件

    Java Swing編寫一個簡單的計算器軟件

    大家好,本篇文章主要講的是Java Swing編寫一個簡單的計算器軟件,感興趣的同學趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • Java 歸并排序算法、堆排序算法實例詳解

    Java 歸并排序算法、堆排序算法實例詳解

    這篇文章主要介紹了Java 歸并排序算法、堆排序算法實例詳解,需要的朋友可以參考下
    2017-05-05
  • SpringBoot?替換?if?的參數(shù)校驗示例代碼

    SpringBoot?替換?if?的參數(shù)校驗示例代碼

    Spring?Validation是對hibernate?validation的二次封裝,用于支持spring?mvc參數(shù)自動校驗,接下來,我們以spring-boot項目為例,介紹Spring?Validation的使用,需要的朋友可以參考下
    2022-12-12
  • IDEA創(chuàng)建yml文件不顯示小樹葉創(chuàng)建失敗問題的解決方法

    IDEA創(chuàng)建yml文件不顯示小樹葉創(chuàng)建失敗問題的解決方法

    這篇文章主要介紹了IDEA創(chuàng)建yml文件不顯示小樹葉創(chuàng)建失敗問題的解決方法,需要的朋友可以參考下
    2020-07-07
  • SpringMVC中Model與Session的區(qū)別說明

    SpringMVC中Model與Session的區(qū)別說明

    這篇文章主要介紹了SpringMVC中Model與Session的區(qū)別說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-12-12

最新評論