码迷,mamicode.com
首页 > 移动开发 > 详细

spring: @RequestMapping注解

时间:2018-01-22 13:11:39      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:import   pos   ram   bin   get   method   mapping   request   framework   

处理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";
	}
}

  

spring: @RequestMapping注解

标签:import   pos   ram   bin   get   method   mapping   request   framework   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!