sping入门
SpringMVC
1、RequestMapping 處理地址映射請求
??? 參數: value, produces, method, params, headers
??? value:指定請求的實際地址
??? 1、最基本
@RequestMapping(value="/departments") public String simplePattern(){ System.out.println("simplePattern method was called"); return "someResult"; }? 通過訪問 http://localhost:8080/***/departments,可以進入函數
? 2、綁定參數
@RequestMapping(value="/departments") public String findDepatment( @RequestParam("departmentId") String departmentId){ System.out.println("Find department with ID: " + departmentId); return "someResult"; }?
? 形如這樣的訪問形式:
?? /departments?departmentId=23就可以觸發訪問findDepatment方法了
3 REST風格參數
RequestMapping(value="/departments/{departmentId}") public String findDepatment(@PathVariable String departmentId){ System.out.println("Find department with ID: " + departmentId); return "someResult"; }形如REST風格的地址訪問,比如:
/departments/23,其中用(@PathVariable接收rest風格的參數
?
轉載于:https://www.cnblogs.com/zhaopAC/p/7275891.html
總結
- 上一篇: python学习(十八) 程序打包
- 下一篇: JVM内存计算问题