How to bind HTTP GET Request parameters to JavaBean object variables?

In this period I am studying the Sping MVC showcase example dowlodable form STS dashboard. In the Request Data section is shown how to bind the parameter of an HTTP GET Request to the homonymous variables of a JavaBean. In practice I have the following link: "> Group of query parameters This link generate a GET HTTP Request towards the "/data/group" URL. This request carries 3 parameter named param1, param2, param3. This request is handled by the following method of my controller class: @RequestMapping(value="group", method=RequestMethod.GET) public @ResponseBody String withParamGroup(JavaBean bean) { return "Obtained parameter group " + bean; } The withParamGroup() method thake a JavaBean object that is only an object that contains 3 variables and getters/setters methods, something like this: public class JavaBean { private String param1; private String param2; private String param3; // GETTER & SETTER method } So the param1 parameter in the HTTP Request is stored in the param1 variable of the JavaBean Object, and the same thing for param2 and param3. Ok...I think that this is clear for me...but...who does this operation? Is it automatically made by Spring framework? Why I have not to use something like @RequestParam annotation as I do when I bind a single HTTP Request parameter with a single variable in the controller method? Another doubt is: the HTTP parameters names have to be the same of the JavaBean variables or simply the first parameter value is stored in the first variable of the JavaBean object? Thanks Andrea

以上就是How to bind HTTP GET Request parameters to JavaBean object variables?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏