开发者

@RequestBody being set but not sure how

开发者 https://www.devze.com 2023-04-13 09:34 出处:网络
So this is a super novice question. Im running this tutorial and in some of the methods like this: @RequestMapping(value=\"/string\", method=RequestMethod.POST)

So this is a super novice question. Im running this tutorial and in some of the methods like this:

@RequestMapping(value="/string", method=RequestMethod.POST)
public @ResponseBody String readString(@RequestBody String string) {
    return "Read string '" + string + "'";
}

where there is a string as a requestbody, the string is foo but i don't know how it is set. Is there some method somewhere that sets a default or what (maybe i'm missing something super obvious). The html looks like this

<form id="readString" class="textForm" act开发者_开发百科ion="<c:url value="/messageconverters/string" />" method="post">
    <input id="readStringSubmit" type="submit" value="Read a String" />
</form>

Thanks for any help you can provide.


As far as I understand the "@RequestBody String string" variable is being set by Spring when you submit your html form using the using post request method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号