提交表单后,表单变量不会显示.冷融合 [英] Form Variables are not showing up after form submit. ColdFusion

查看:236
本文介绍了提交表单后,表单变量不会显示.冷融合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<form name="abc" id="abc" method="post" action="/test.cfm" enctype="multipart/form-data">
<input type="submit" name="btnSubmit" id="btnSubmit" value="OK" />
</form>

由于某些原因,当我点击提交时,"btnSubmit"未显示在cfdump中.

for some reason when I hit submit the "btnSubmit" is not showing up in the cfdump.

<cfdump var="#form#">

推荐答案

没有很多事情可以使它根本不会出现在您的表单中.我的罪魁祸首是:

There aren't a lot of things that could cause it to simply not appear in your form. My short-list of culprits are:

  • 正在查找错误的文件/服务器.
  • 正在通过cflocation或其他方式(javascript location.replace()或location.href = x)重定向页面-即使重定向将浏览器返回到同一页面,也会导致该问题.
  • onRequestStart
  • 中,表单变量被进一步剥离
  • 创建了一个名为"variables.form"的局部变量,并将其设置为更高级的结构-不太可能,但是我想这可能是某人可能不小心写了类似<cfset form = url />的内容,这可能导致
  • Looking at the wrong file / server.
  • The page is being redirected via cflocation or otherwise (javascript location.replace() or location.href=x) -- this would cause that problem even if the redirection is returning the browser to the same page.
  • Form variables being stripped out somewhere further up, I would guess in onRequestStart
  • A local variable named "variables.form" was created and set to a structure further up - not very likely, but I suppose it's possible someone could accidentally write something like <cfset form = url />, which might cause that

通常,过去发生这种情况时,我发现我在浏览器中查看了错误的文件.通常情况下,我会在错误的域名下查看同一文件,例如查看生产服务器而不是开发服务器.

Usually, when something like this has happened to me in the past, I've found that I've been viewing the wrong file in the browser. Usually it's come down to me looking at the same file on the wrong domain name, e.g. looking at the production server instead of the development server.

如果将上面的代码段组合成一个这样的文件(test.cfm):

If you combine your code segments above into a single file like this (test.cfm):

<cfdump var="#form#" />

<form name="abc" id="abc" method="post" action="test.cfm" enctype="multipart/form-data">
<input type="submit" name="btnSubmit" id="btnSubmit" value="OK" />
</form>

这应该使您对问题有所了解.请注意,我在表单操作中删除了前导斜线/,以便此表单可以发布到自身.当我第一次查看此模板时,我看到一个空结构(后跟按钮),因为我还没有在表单范围内放置任何内容.提交表单后,我会在结构中看到两个元素,即字段名和btnSubmit.这是另一个很好的指示,如果您在表单结构中看不到字段名,则您的CFML页面可能尚未收到表单提交.如果您知道自己在看正确的页面,并且已经提交了表单,但仍然没有fieldnames条目,那么我将开始寻找潜在的浏览器重定向.

That ought to give you some insight into your problem. Note that I removed the leading-slash / in the form action, so that this form will post to itself. When I first view this template, I see an empty struct (followed by the button), because I haven't put anything in the form scope yet. When I submit the form I then see two elements in the structure, fieldnames and btnSubmit. That's another good indicator, if you don't see fieldnames in the form structure, then your CFML page may not have received a form submission. If you know you're looking at the right page and you've submitted the form and you still don't have the fieldnames entry, then I'd start looking for potential browser redirection.

您可能还想在同一目录中添加一个空的Application.cfc,以确保没有任何应用程序干扰它. onRequestStart中的某些内容可能会剥离名称为"btnSubmit"的表单变量,甚至剥离名称中任何位置为字符串"submit"的任何表单变量.我不希望如此-我会首先寻找其他原因,例如cflocation标记.

You might also want to add an empty Application.cfc in the same directory just to be sure that there's not an application interfering with it. It's possible that something in the onRequestStart might be stripping out form variables with the name "btnSubmit" or even any form variable with the string "submit" anywhere in the name. I wouldn't expect it though -- I'd look for other causes like cflocation tags first.

这篇关于提交表单后,表单变量不会显示.冷融合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆