使用sprint Spring 4.3。现在情况已经发生了变化。现在您可以在处理http请求的方法上使用@GetMapping。类级@RequestMapping规范使用(方法级)@GetMapping注释进行了细化
这里有一个例子:
@Slf4j
@Controller
@RequestMapping("/orders")/* The @Request-Mapping annotation, when applied
at the class level, specifies the kind of requests
that this controller handles*/
public class OrderController {
@GetMapping("/current")/*@GetMapping paired with the classlevel
@RequestMapping, specifies that when an
HTTP GET request is received for /order,
orderForm() will be called to handle the request..*/
public String orderForm(Model model) {
model.addAttribute("order", new Order());
return "orderForm";
}
}