@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。