Apache Velocity中的小写首字母

时间:2015-11-09 14:53:10

标签: webstorm velocity jetbrains-ide

我有这个代码,它将“点”字符串转换为WebStorm文件模板中的camelCase:

#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})

例如,它会将foo.bar.test转换为FooBarTest

但我需要的是将其从foo.bar.test转换为fooBarTest

我该怎么做?

1 个答案:

答案 0 :(得分:15)

这最终对我有用:

#set($Controller_name = ${StringUtils.removeAndHump(${NAME}, ".")})
#set($first_letter = $Controller_name.substring(0,1).toLowerCase())
#set($the_rest = $Factory_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指出我正确的方向。