这是我的代码:
<cffunction name="onRequest">
<cfargument name="templatename">
<cflogin>
<cfif form.submit IS NOT "">
<cfif form.username IS "user" AND form.username IS "pass">
<cfloginuser name="#form.username#" password="#form.password#" roles="admin">
<cfelse>
<cfset request.errorMessage = "Wrong username or password. Please try again.">
<cfinclude template="login.cfm">
<cfreturn>
</cfif>
<cfelse>
<cfinclude template="login.cfm">
<cfreturn>
</cfif>
</cflogin>
<cfinclude template="#arguments.templatename#">
</cffunction>
我收到以下错误:
Context validation error for the cfargument tag.
The tag must be nested inside a CFFUNCTION tag.
The error occurred in C:/ColdFusion11/cfusion/wwwroot/myApp/administrator/Application.cfc: line 9
7 :
9 : <cfargument name="templatename">
10 :
11 : <cflogin>
任何人都可以帮助我吗?
我正在使用ColdFusion 11试用
答案 0 :(得分:0)
此代码中的代码 -
<cfif form.username IS "user" AND form.username IS "pass">
<cfloginuser name="#form.username#" password="#form.password#" roles="admin">
您正在检查form.username两次,其中两个值为&#34; AND&#34;运营商。 我想这应该是这样的: -
<cfif form.username IS "user" AND form.password IS "pass">
<cfloginuser name="#form.username#" password="#form.password#" roles="admin">