十一、使用@RequestParam注解指定参数的name

十一、使用@RequestParam注解指定参数的name

https://www.cnblogs.com/sunniest/p/4555801.html

复制代码
@Controller
@RequestMapping("/test")
public class mvcController1 {
    @RequestMapping(value="/param")
    public String testRequestParam(@RequestParam(value="id") Integer id,
            @RequestParam(value="name")String name){
        System.out.println(id+" "+name);
        return "/hello";
    }    
}
    // http://localhost:8080/HiSpringMVC/jim/param?id=1&name=Green
    //http://localhost:8080/HiSpringMVC/jim/param?id=21&name=Geek
    @RequestMapping(value="/param")
    public String testRequestParam(@RequestParam(value="id") Integer id,
            @RequestParam(value="name")String name){
        System.out.println(id+" "+name);
        return "hello";
    }

 

    //@RequestParam(value="id") Integer id
    // http://localhost:8080/HiSpringMVC/jim/param?id=1&name=Green
    //http://localhost:8080/HiSpringMVC/jim/param?id=21&name=Geek
    //
    //http://localhost:8080/HiSpringMVC/jim/param?NO=21&name=Geek
    @RequestMapping(value="/param")
    public String testRequestParam(@RequestParam(value="NO") Integer id,
            @RequestParam(value="name")String name){
        System.out.println(id+" "+name);
        return "hello";
    }

 

posted @ 2018-01-10 19:04  sky20080101  阅读(1498)  评论(0)    收藏  举报