what is the correct syntax of a post form in an http request
What is the format of a form sent in an http post request ? I am trying an http client program and want to send a form in an http post request. I tried :
< FORM METHOD=POST >
< INPUT name="name" value="chriss"&开发者_JS百科gt;
< /FORM >
is this correct ? on the server side, when I try to get the value of name ( i use : form.getFirstValue("name")) I get null. (I am using restlet as my API.) Can anyone help me please
The body of the POST
request sent by an HTML form is usually using the "application/x-www-form-urlencoded
" media type.
If your client is also a Restlet client, you should be able to use the Form
class, set the required values for each name/value pairs, and get the representation to send using getWebRepresentation()
.
Essentially, the body will look like this:
name=chriss
If you had more parameters, they would be separated by &
.
(If you were sending files, you'd use the multipart/form-data
encoding instead.)
An HTML reference will be helpful. There are plenty of good HTML books and online references.
<form method="post" action="/url/to/submit/to">
<input type="text" name="name" value="chriss">
</form>
精彩评论