gpt4 book ai didi

java - 元素大小代表什么?

转载 作者:行者123 更新时间:2023-11-29 06:51:32 24 4
gpt4 key购买 nike

我将注释 @Size 视为 Spring Controller 中的限制。我正在寻找关于尺寸到底是多少的解释,我发现了这个:

The size of the field or property is evaluated and must match the specified boundaries. If the field or property is a String, the size of the string is evaluated. If the field or property is a Collection, the size of the Collection is evaluated. If the field or property is a Map, the size of the Map is evaluated. If the field or property is an array, the size of the array is evaluated. Use one of the optional max or min elements to specify the boundaries.

但是我不清楚如何计算字符串的大小。它是其中的字符数吗?是字节数吗?有人知道吗?

最佳答案

你没有说你在哪里找到了那个解释,但是 javax.validation.constraints.Size Javadoc

The annotated element size must be between the specified boundaries (included).
Supported types are:

CharSequence (length of character sequence is evaluated)
Collection (collection size is evaluated)
Map (map size is evaluated)
Array (array length is evaluated)

null elements are considered valid.

注意 String 是一个 CharSequence

关于java - 元素大小代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46661775/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com