ColdFusion-9“includeEmptyValues”
这是我的代码:
returnStruct.myList = myList;
returnStruct.first = trim(ListGetAt(myList,3));
returnStruct.last = trim(ListGetAt(myList,13));
returnStruct.address = trim(ListGetAt(myList,15));
returnStruct.city = trim(ListGetAt(myList,2));
returnStruct.state = trim(ListGetAt(myList,9));
一切正常,直到 myList
遇到空值,然后一切崩溃。 我发现了一个命令“includeEmptyValues”,我可以将其设置为“yes”,但我不熟悉它,而且 ColdFusion 9 的文档也不是我遇到过的最好的。
This is my code:
returnStruct.myList = myList;
returnStruct.first = trim(ListGetAt(myList,3));
returnStruct.last = trim(ListGetAt(myList,13));
returnStruct.address = trim(ListGetAt(myList,15));
returnStruct.city = trim(ListGetAt(myList,2));
returnStruct.state = trim(ListGetAt(myList,9));
Everything is working fine until myList
hits empty values and then everything crashes.
I found a command "includeEmptyValues" that I can set to 'yes' but I am not familiar with it and the documentation of ColdFusion 9 isn't the best I've come across.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://cfquickdocs.com/cf9/#listgetat
ColdFusion 的早期版本(默认为 CF9)将连续分隔符计为单个分隔符。因此,看起来像这样的列表:
被认为有四个元素。
最近添加的是“includeEmptyValues”属性。
因此 while
会抛出错误,
并成功将
myVar
设置为d
。http://cfquickdocs.com/cf9/#listgetat
Previous versions of ColdFusion (and CF9 by default) counted consecutive delimiters as a single delimiter. So a list that looked like this:
was considered to have four elements.
Recently added is the "includeEmptyValues" attribute.
So while
will throw an error
will successfully set
myVar
tod
.可能想要使用 listToArray() 和 ArrayIsDefined()。使用 includeEmptyFields attr 并查看您喜欢哪种行为。 True = 将列表中的空元素转换为空数组条目
might want to use listToArray(), and ArrayIsDefined(). Play with includeEmptyFields attr and see which behavior you prefer. True = Convert empty elements in a list to empty array entries