W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
轉(zhuǎn)換器:converter
格式化:Format
在“校驗(yàn)器”、“文件上傳”中的例子中都使用了數(shù)據(jù)綁定(將表單數(shù)據(jù)綁定到bean對(duì)象中),例如:
@RequestMapping(value = "/output")
public String output(Person person, Model model) {
model.addAttribute("person", person);
return "hello/output";
}
表單的數(shù)據(jù)都是String類型,如果我們的bean類中的屬性是其他類型,例如Date、int,這時(shí)候就需要寫一個(gè)工具,將String轉(zhuǎn)換成Date、int。
這就是轉(zhuǎn)換器與格式化做的事情:類型轉(zhuǎn)換。字符串轉(zhuǎn)換成數(shù)字類型是內(nèi)置的。
資料:
9. Validation, Data Binding, and Type Conversion
Spring MVC request parameter conversion with minimal configuration
Introduction to Spring Converters and Formatters
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: