java - Any simple way to test a @RequestBody method? -
if have @controller
method parameter @requestbody
param, have write jquery script or similar perform ajax request json
object in order call method. if tried calling method via web browser directly, returns error 415 unsupported media type
.
is there alternative call such method using browser without having write jquery
code? perhaps way write json
object in url/address bar?
code:
@requestmapping("testcall") @responsebody public list<testobject> gettestcall (@requestbody testparams testparams) { return stuff; } public class testparams { private integer testnumber; //getter/setter testnumber }
i thought maybe do:
http://localhost/testcall?testnumber=1
maybe spring auto populate new testparams instance property set 1 didnt work...
maybe need that?
the whole point of @requestbody
annotated parameters spring mvc stack use http request body produce argument bound parameter. such, need provide request body. sending request body atypical request. such, browsers don't typically support it, @ least not when entering address in address bar , submitting request.
you'll need use different http client, jquery. typically have small java project in eclipse that's setup apache http components client can send http requests whatever server. takes few seconds/minutes setup correct request body , run.
Comments
Post a Comment