我想找到一种将下面的 html 提交给 cfc 函数的最佳方法。
<form action="test.cfc">
<input type="hidden" name="method" value="save">
<input type="text" name="mytext[]" value="f,oo">
<input type="text" name="mytext[]" value="bar">
<input type="submit">
</form>
test.cfc 文件内容:
<cfcomponent displayname="test">
<cffunction name="init">
<cfreturn this>
</cffunction>
<cffunction name="save" output="false" returnformat="JSON" access="remote">
<cfargument name="mytext" type="string" required="true">
<!--- ***comments***
i want to do this:
<cfloop list="arguments.mytext" index="curRowValue">
<cfquery blah blah...>
insert into fooBar (stuff) values (curRowValue)
</cfquery
</cfloop>
--->
<cfreturn arguments>
</cffunction>
</cfcomponent>
'test.save()' 函数将在我的设置{mytext:"f,oo,bar"}
中返回此 json,如果我取消注释插入代码,它将插入 3 行而不是 2 行。混合用户输入的文本和coldfusion的标准列表分隔符的正确方法是什么?