方式1
使用CaseUtils 对Java字符串进行转换为驼峰格式:
CaseUtils.toCamelCase(null, false) = null
CaseUtils.toCamelCase("", false, *) = ""
CaseUtils.toCamelCase(*, false, null) = *
CaseUtils.toCamelCase(*, true, new char[0]) = *
CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'}) = "toCamelCase"
CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'}) = "ToCamelCase"
CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'}) = "toCamelCase"
构造方法:
public static String toCamelCase(String str,
boolean capitalizeFirstLetter,
char... delimiters)
其中:str为要转换的字符串;capitalizeFirstLetter表示是否首字母大写;delimiters指定连词符。
maven依赖:
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-text -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
</dependency>
方式2
使用Google Guava
的 com.google.common.base.CaseFormat。
引入依赖:
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
使用:
CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, string_to_format)
最新评论
网飞没问题, 迪士尼+有解决方案么?
pp助手是安卓手机用的,根本下载用不来苹果
已解决
这样的话数据库里的结构为{"attachment":{"content":"xxx"}}, 要怎么才能变成{"content":"xxx"},从而使结构保持一致?
赞! make test不过的坑都写到的,谢谢楼主~
谢谢你
用了root用户还是一直502是怎么回事呢
student id 是空的