简体   繁体   English

html形式的“ action ='。'”条目是什么意思?

[英]What does an entry “action='.'” in html form mean?

我在方法发布的代码中看到了这一点,但无法弄清楚它到底是做什么的。

<form action="." method="POST" class="form-vertical">

. is the current path segment of the current URL. 是当前URL的当前路径段 In other words, it refers to the current relative URL. 换句话说,它指的是当前相对URL。

If your current URL is http://example.com/foo/bar/baz/ , then . 如果您当前的网址是http://example.com/foo/bar/baz/ ,那么. refers to http://example.com/foo/bar/baz/ (yes, same URL). http://example.com/foo/bar/baz/ (是的,相同的URL)。

It's a bit trickier without a trailing slash. 没有尾随的斜杠会比较棘手。 On http://example.com/foo/bar/baz , . http://example.com/foo/bar/baz. refers to http://example.com/foo/bar/ . 参考http://example.com/foo/bar/ That's why it's not usually a good idea to use . 这就是使用它通常不是一个好主意的原因. ; ; you could use action="" instead, which means action has an empty value, in which case the current (full) URL is substituted. 您可以改用action="" ,这意味着action有一个空值,在这种情况下,将替换当前(完整)URL。

This . 这个. is pretty universal and is used in many contexts involving URLs or file paths. 是非常通用的,并且在涉及URL或文件路径的许多上下文中使用。

Action normally specifies the file/page that the form is submitted to using the method described in the method parameter post or get. 动作通常指定使用方法参数post或get中描述的方法将表单提交到的文件/页面。

. (dot) is the current path. (点)是当前路径。 you can try a demo here http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_submit 您可以在此处尝试演示http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_submit

try to upload your form using action="." 尝试使用action =“上传您的表单。” or action="" or action="/" 或action =“”或action =“ /”

you will see the difference 你会看到差异

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM