spring: @RequestMapping注解

处理GET/POST请求方法

1.常用的:

import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HomeController {

	
	//处理"/"的GET请求方法1
	@RequestMapping(value="/",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";
	}
}

  

原文地址:https://www.cnblogs.com/achengmu/p/8328364.html