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

spring-mvc属性编辑器绑定跟传文件

2012-10-08 
spring-mvc属性编辑器绑定和传文件?@InitBinderpublic void initBinder(WebDataBinder binder) {// 忽略字

spring-mvc属性编辑器绑定和传文件

?

@InitBinderpublic void initBinder(WebDataBinder binder) {// 忽略字段绑定异常binder.setIgnoreInvalidFields(true);DateFormat format = new SimpleDateFormat("yyyy-MM-dd");binder.registerCustomEditor(Date.class, "buyDate",new CustomDateEditor(format, true));binder.registerCustomEditor(Date.class, "brPhoneDate",new CustomDateEditor(format, true));binder.registerCustomEditor(Date.class, "brDate",new CustomDateEditor(format, true));}

?// 通过excel导入手机卡数据

?

@RequestMapping(value = "phone/excel/input.do")public ModelAndView upload(@RequestParam(value = "file", required = false) MultipartFile file) {try {if (file != null)this.phoneService.addByExcel(file.getInputStream());return new ModelAndView("redirect:/phones.do");} catch (Exception e) {e.printStackTrace();return new ModelAndView("error", "message", "导入数据失败");}}
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
?

热点排行