5、似“/favsoft”这样的URL映射到整个类或特定的处理方法上。一般来说,类级别的注解映射特定的请求路径到表单控制器上,而方法级别的注解只是映射为一个特定的HTTP方法请求(“GET”,“POST”等)或HTTP请求参数。 123456789101112@Controller@RequestMapping("/favsoft")public class AnnotationController { @RequestMapping(method=RequestMethod.GET) public String get(){
6、 return ""; } @RequestMapping(value="/getName", method = RequestMethod.GET) public String getName(String userName) { return userName; } 131415161718192021222324252627282930 @RequestMapping(value="/{day}", method=RequestMethod.GET) public
7、String getDay(Date day){ DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(day); } @RequestMapping(value="/addUser", method=RequestMethod.GET) public String addFavUser(@Validated FavUser favUser,BindingResult result){ if(re