首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

Spring MVC的检讨机制填充

2012-10-27 
Spring MVC的自省机制填充//User实例package spr.webimport java.util.Dateimport java.text.SimpleDate

Spring MVC的自省机制填充


//User实例
package spr.web;import java.util.Date;import java.text.SimpleDateFormat;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.propertyeditors.CustomDateEditor;import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.WebDataBinder;import org.springframework.web.bind.annotation.InitBinder;import org.springframework.web.bind.annotation.RequestMapping;import spr.domain.*;import spr.service.*;@Controller@RequestMapping("/user.htm")public class UserController {@Autowiredprivate UserServiceAble userService;//日期类型映射器@InitBinderpublic void initBinder(WebDataBinder binder){SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd");binder.registerCustomEditor(Date.class, new CustomDateEditor(df, false));}@RequestMapping(params="op=doAdd")public String doAdd(User user){System.out.println(user.getName());userService.addUser(user);return "redirect:user.htm?op=list";}}

热点排行