package zpark.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import zpark.entity.User;
/**
* @controller 单例
* @Scope("prototype") 多例
*/
@Controller
@RequestMapping("/restFul")
public class RestFulController {
/**
* 多个参数:
* @PathVariable 获取{}中的值
* 若方法参数名称和{}中变量名称不一致,需要在@PathVariable("name")指定名称。
*
* @param id
* @param name
* http://localhost:9999/restFul/find/123/aa
*/
@RequestMapping(value="/find/{myId}/{name}",method=RequestMethod.GET)
public String test(@PathVariable(value="myId") Integer id,@PathVariable String name){
System.out.println(id);
System.out.println(name);
return "index";
}
/**
* 一个参数
* @param id
* @param name
* http://localhost:9999/restFul/json/123
*/
@RequestMapping(value="/json/{id}")
public String test1(@PathVariable Integer id, String name){
System.out.println(id);
System.out.println(name);
return "index";
}
}