In the development, not familiar with the driver-driven test development coder often like to start the service application after the test, for GET request can be directly in the browser input URL can be, parameter non-Chinese can be directly appended to the URL. However, testing for other requests must be done with the appropriate controls, such as a restful architecture.
The SPRINGMVC framework is part of the spring framework and provides good support for restful. SPRINGMVC can accept JSON-type data, or convert entities to JSON to return to the client. Restclient is a plug-in for an HTTP request from Mozilla Firefox, which can select the request method, specify the request header, and add the request body.
The completion of the HTPP request can be delineated as three parts from the data's point of view: Data Issuance--"data processing--" returns. This article mainly discusses HTTP parameter mappings based on SPRINGMVC and restclient controls.
Using the browser directly to enter the URL link, SPRINGMVC controller can directly accept the corresponding request parameter values,
The browser operates as follows:
Notice that the HTTP request Content-type is application/xhtml+xml, if you set the Content-type of the request header to a different value will it normally accept?
Create a new Post request processing method, two parameters, at this time through the Restclient issued a request as follows:
The background output is as follows:
This shows that the background does not accept the age parameter data. Now change the request header as follows
Request response status is 200ok, view background output:
Normal output in the background.
Summarize:
When using Restclient for request testing, if the background cannot accept parameter data, the configuration of the request header should be checked.
Testing of rest services based on SPRINGMVC and restclient