我有这段代码,它将“点分”字符串转换为 WebStorm 文件模板中的驼峰命名法:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
例如,它将 foo.bar.test
转换为 FooBarTest
。
但我需要的是将其从 foo.bar.test
转换为 fooBarTest
。
我怎样才能做到这一点?
最佳答案
这最终对我有用:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($first_letter = $Controller_name.substring(0,1).toLowerCase())
#set($the_rest = $Controller_name.substring(1))
#set($Controller_name = ${first_letter} + ${the_rest})
可以缩短为:
#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($Controller_name = $Controller_name.substring(0,1).toLowerCase() + $Controller_name.substring(1))
感谢@LazyOne 为我指明了正确的方向。
关于webstorm - Apache Velocity 中的第一个字母小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33611802/