4. 常用注解
????4.1 @RequestParam
? ? 4.2?@RequestBody
? ? 4.3?@PathVariable
????4.4 @RequestHeader
????4.5 @CookieValue
? ??4.6 @ModelAttribute
? ??4.7 @SessionAttributes
5. 返回值類型
????5.1 string:
? ??5.2 void:
????5.3 ModelAndView:
? ??5.4?forward 與?redirect
? ??5.5 靜態(tài)資源過濾與響應json
6. 文件上傳
????6.1?fileupload組件文件上傳
? ??6.2 springmvc的文件上傳
4. 常用注解
????4.1 @RequestParam
????????@RequestParam:將請求參數(shù)綁定到你控制器的方法參數(shù)上
????4.2 @RequestBody
????????@RequestBody:接收請求體數(shù)據(jù)(前端傳遞給后端的json字符串中的數(shù)據(jù))
????4.3 @PathVariable
????????@PathVariable:URL綁定的占位符
? ? 4.4 @RequestHeader
????????@RequestHeader:獲取header頭信息
????4.5 @CookieValue
????????@CookieValue: 獲取cookie值
????4.6 @ModelAttribute
????????@ModelAttribute:修飾方法和參數(shù)歪沃。在方法上表示當前方法會在控制器的方法執(zhí)行之前先執(zhí)行卒茬。在參數(shù)上昆雀,獲取指定的數(shù)據(jù)給參數(shù)賦值肺蔚。?
? ? ? ? 應用場景:表單提交數(shù)據(jù)不是完整的實體類數(shù)據(jù)時骤肛,保證沒有提交數(shù)據(jù)的字段使用數(shù)據(jù)庫對象原來的數(shù)據(jù)。
????4.7 @SessionAttributes
????@SessionAttributes: 用于多次執(zhí)行控制器方法間的參數(shù)共享
5. 返回值類型
????5.1 string:
????????Controller方法返回字符串可以指定邏輯視圖的名稱澳化,根據(jù)視圖解析器為物理視圖的地址召边。
????5.2 void:
????5.3 ModelAndView:
????5.4?forward 與?redirect
? ? 5.5 靜態(tài)資源過濾與響應json
6. 文件上傳
? ? 6.1?fileupload組件文件上傳
? ? ? ? 安裝?commons-fileupload,commons-io
6.2 springmvc的文件上傳
6.3 跨服務器上傳
????????安裝jersey-core吉挣,jersey-client