gpt4 book ai didi

coldfusion - 如何在 CFscript 中指定参数属性? (CF9)

转载 作者:行者123 更新时间:2023-12-03 09:50:39 24 4
gpt4 key购买 nike

在 CF9 文档中:Defining components and functions in CFScript ,它说:

/** 
*Comment text, treated as a hint.
*Set metadata, including, optionally, attributes, in the last entries
*in the comment block, as follows:
*@metadataName metadataValue
...
*/
access returnType function functionName(arg1Type arg1Name="defaultValue1"
arg1Attribute="attributeValue...,arg2Type
arg2Name="defaultValue2" arg2Attribute="attributeValue...,...)
functionAttributeName="attributeValue" ... {
body contents
}

如何指定arg1Attribute?我试过这个:

public void function setFirstname(string firstname="" displayName="first name"){}

但它不起作用。

此外,如何将其转换为脚本样式?

<cffunction name="setPerson">
<cfargument name="person" type="com.Person"/>
</cffunction>

我试过:

function setPerson(com.Person person){}

它也不起作用。它说:“在此上下文中,您不能将变量引用与“.”运算符一起使用。

最佳答案

原来这是一个文档错误。无法为脚本 block 中的参数提供元数据。您可以执行提示、必需、类型和默认值,但不能执行其他操作。我在问关于 com.Person 的事情。 Mark Mandel 建议导入 com 并只使用 Person。

关于coldfusion - 如何在 CFscript 中指定参数属性? (CF9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1591716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com