文章詳情頁
java - spring mvc接收的是一個(gè)對象,怎么對對象每個(gè)屬性進(jìn)行不同的設(shè)置?
瀏覽:179日期:2023-11-19 08:50:38
問題描述
@RequestMapping(value = '/listByUserId')public PageInfo<Product> listByUserId(User user) { }
請問接收的是一個(gè)User對象,其中User的屬性id,我想給它設(shè)置一個(gè)初始值,也就是在未送id參數(shù)時(shí)有個(gè)初始值,我使用@RequestParam指定id屬性defalutValue不行,請問有什么辦法實(shí)現(xiàn)?最好不要改動(dòng)到User類
問題解答
回答1:我是這樣寫的:
@RequestMapping(value='/student/{st_no}',method= RequestMethod.GET)public Student info(@PathVariable Integer st_no){}
標(biāo)簽:
java
排行榜

熱門標(biāo)簽
網(wǎng)公網(wǎng)安備