0
以下是將enctype屬性添加到表單標記並觀察傳遞的參數丟失的一個簡單示例。Coldfusion 10 Rest Services和enctype的剩餘資源值應該是多少?
## test.rest.cfm
<!doctype html>
<html>
<head>
<title>Test Form</title>
</head>
<body>
<div>
<p>Will Post From Here</p>
<form method="post" action="http://devserver/rest/ost/testform/" name="frmName">
<table>
<tr>
<td>fname</td>
<td><input type="text" name="fname" id="fname" value="Fredley"></td>
</tr>
<tr>
<td>lname</td>
<td><input type="text" name="lname" value="Solongo"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Post"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
## testFormHandler.cfc
<cfcomponent restpath="testform" rest="true" produces="application/JSON">
<cffunction description="POST method to test form"
name = "postMethod"
access = "remote"
output = "false"
returntype = "string"
returnformat = "json"
httpmethod = "post" >
<cfargument required="1" type="any" restArgSource="Form" name="fname">
<cfargument required="1" type="any" restArgSource="Form" name="lname">
<cfset var arrayReturn = {}>
<cfset arrayReturn["fname"] = arguments.fname>
<cfset arrayReturn["lname"] = arguments.lname>
<cfreturn "{""PayLoad"":" & SerializeJSON(arrayReturn) & ",""Type"":""Success"",""Message"":""SUCCESS"",""Code"":""SUCCESS""}">
</cffunction>
</cfcomponent>
## change form tag of test.rest.cfm to gets param fname failure
<form method="post" action="http://dev1.ostit.com/rest/ost/testform/" name="frmName" enctype="multipart/form-data">
## results with no enctype
{"PayLoad":{"fname":"Fredley","lname":"Solongo"},"Type":"Success","Message":"SUCCESS","Code":"SUCCESS"}
## results with enctype added
{"Message":"The FNAME parameter to the postMethod function is required but was not passed in."}
當包含enctype時restArgSource應該不同麼?顯然,HTTP頭改變,但使用頭與restargname沒有工作,要麼...