Merging other languages

This commit is contained in:
James Miranda
2016-09-23 18:01:10 -03:00
parent 380a8ee74c
commit de3c5bdaa4
490 changed files with 24539 additions and 24588 deletions

View File

@@ -1,25 +1,23 @@
# 4 表单
表单是我们平常编写Web应用常用的工具通过表单我们可以方便的让客户端和服务器进行数据的交互。对于以前开发过Web的用户来说表单都非常熟悉但是对于C/C++程序员来说,这可能是一个有些陌生的东西,那么什么是表单呢?
表单是一个包含表单元素的区域。表单元素是允许用户在表单中(比如:文本域、下拉列表、单选框、复选框等等)输入信息的元素。表单使用表单标签(\<form\>)定义。
<form>
...
input 元素
...
</form>
Go里面对于form处理已经有很方便的方法了在Request里面的有专门的form处理可以很方便的整合到Web开发里面来4.1小节里面将讲解Go如何处理表单的输入。由于不能信任任何用户的输入所以我们需要对这些输入进行有效性验证4.2小节将就如何进行一些普通的验证进行详细的演示。
HTTP协议是一种无状态的协议那么如何才能辨别是否是同一个用户呢同时又如何保证一个表单不出现多次递交的情况呢4.3和4.4小节里面将对cookie(cookie是存储在客户端的信息能够每次通过header和服务器进行交互的数据)等进行详细讲解。
表单还有一个很大的功能就是能够上传文件那么Go是如何处理文件上传的呢针对大文件上传我们如何有效的处理呢4.5小节我们将一起学习Go处理文件上传的知识。
## 目录
![](images/navi4.png?raw=true)
## links
* [目录](<preface.md>)
* 上一章: [第三章总结](<03.5.md>)
* 下一节: [处理表单的输入](<04.1.md>)
# 4 User form
A user form is something that is very commonly used when developping web applications. It provides the ability to communicate between clients and servers. You must be very familiar with forms if you are a web developer; if you are a C/C++ programmer, you may want to ask: what is a user form?
A form is an area that contains form elements. Users can input information into form elements like text boxes, drop down lists, radio buttons, check boxes, etc. We use the form tag `<form>` to define forms.
<form>
...
input elements
...
</form>
Go already has many convenient functions to deal with user forms. You can easily get form data in HTTP requests, and they are easy to integrate into your own web applications. In section 4.1, we are going to talk about how to handle form data in Go. Also, since you cannot trust any data coming from the client side, you must first verify the data before using it. We'll go through some examples about how to verify form data in section 4.2.
We say that HTTP is stateless. How can we identify that certain forms are from the same user? And how do we make sure that one form can only be submitted once? We'll look at some details concerning cookies (a cookie is information that can be saved on the client side and added to the request header when the request is sent to the server) in both sections 4.3 and 4.4.
Another big use-case of forms is uploading files. In section 4.5, you will learn how to do this as well as controlling the file upload size before it begins uploading, in Go.
## Links
- [Directory](preface.md)
- Previous chapter: [Chapter 3 Summary](03.5.md)
- Next section: [Process form inputs](04.1.md)