首页 试题广场 > 试题详情
多选题

【C016053】在SpringMVC中,关于@PathVariable和@RequestParam的区别,正确的是()。

  • A.如果用的是@PathVariable?             
    @RequestMapping(value="/page{pageNo}.do")?
    public String page(@PathVariable int pageNo){}?
    如果用的是@RequestParam ,对于这种参数,如果要用的话,代码如下:?
    @RequestMapping(value="/page.do")?
    public String page(@RequestParam int pageSize,@RequestParam? int pageNow){}?
  • B.两者的作用都是将request里的参数的值绑定到Controller里的方法参数里的
  • C.@PathVariable是从路径里面去获取变量,也就是把路径当做变量,而@RequestParam是从请求里面获取参数
  • D.@PathVariable的url是这样的:http://host:port/.../path/参数值
    @RequestMapping("/bookings/{booking}")?
    public String getBooking(@PathVariable Long booking) {?
    ???????return “bookForm”;
    }
    @RequestParam的url是这样的:http://host:port/.../path?参数名=参数值?
    @RequestMapping(method = RequestMethod.GET)?
    public String setupForm(@RequestParam("petId") int petId, ModelMap model) {
    ??????? Pet pet = this.clinic.loadPet(petId);
    ??????? model.addAttribute("pet", pet);
    ??????? return "petForm";
    }
提交并查看答案
下一题 上一题
Ke星伙伴们的回答/ 5个回答
贡献榜
相关试题
关闭
关闭
QQ
交流群
邀请
好友
App
下载
意见
反馈
返回
顶部