spring: @RequestMapping注解

弱龄寄事外,委怀在琴书。这篇文章主要讲述spring: @RequestMapping注解相关的知识,希望能为你提供帮助。
处理GET/POST请求方法
【spring: @RequestMapping注解】1.常用的:

import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HomeController { //处理"/"的GET请求方法1 @RequestMapping(value="https://www.songbingjia.com/",method=GET) public String home() { return "home"; } }


2常用方法
import org.springframework.web.bind.annotation.RequestMapping; @Controller //处理"/"的GET请求方法2 @RequestMapping("/") public class HomeController { //处理"/"的GET请求方法2 @RequestMapping(method=GET) public String home() { return "home"; } }


3.常用方法,数组
import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping({"/","/homepage"}) public class HomeController { public String home() { return "home"; } }



    推荐阅读