Springmvc -> Controller注解

来源:互联网 发布:asp嵌入java代码 编辑:程序博客网 时间:2024/06/04 17:55
@RestController@RequestMapping("/hello")public class HelloController {    @RequestMapping(value = "/hi/{name}")    public void hi(@PathVariable("name") String name, @RequestParam("msg") String msg) {        System.out.println("Hi " + name + ", " + msg);    }}

@PathVariable

不支持required = false属性,设置为该注解的参数是必填的。

@RequestParam

支持required = false属性,默认为required = true。

原创粉丝点击