這個很簡單,直接上代碼
這裡通過一個接口去查詢到user主鍵為10的資料,然後通過model模闆儲存并傳遞到前端,主要看前端怎麼寫,背景我感覺不是特别難,因為本人主要寫背景,前端這些資料的展示一直都半懂半不懂的,是以特地來總結一下,友善以後查閱
@RequestMapping(value = "/object.action")
public String object(Model model) throws MessageException{
//從Mysql中查詢
User user = itemService.selectUser(10);
model.addAttribute("user",user);
return "object";
}
下面是前端頁面,so esay
<table>
<tr>
<td><input type="text" name="name" value="${user.username }" /></td>
<td><input type="text" name="name" value="${user.birthday }" /></td>
<td><input type="text" name="name" value="${user.sex }" /></td>
</tr>
<tr>
<td><input type="text" name="name" value="${user.address }" /></td>
</tr>
</table>
展示效果