@PathVariable
獲取url中的數據
該註解是實現RESTFull最主要的一個註解
eg:
package com.example.controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.Map; /** * restfull */ @RestController public class RESTFullController { //訪問地址http://localhost:8080//boot/restfullstudent/id/status @RequestMapping("/boot/restfullstudent/{id}/{status}") public Object restfullstudent(@PathVariable("id") Integer id,@PathVariable("status") Integer status){ Map<String,Object> map=new HashMap<String,Object>(); map.put("id",id); map.put("status",status); return map; } }