我正在做一个使用spring mvc和MyEclipse集成开发环境的实时项目,没有集成maven,我的问题是如何在数据库中存储和检索图像和文件。
发布于 2014-07-17 23:53:28
用于在数据库中存储图像文件的控制器代码:
@RequestMapping(value = "/saveproduct")
public ModelAndView add(@ModelAttribute("command") CommonBean cbean,
BindingResult result, HttpServletRequest request) throws Exception {
CommonsMultipartFile file = cbean.getImage();
System.out.println("file content is " + file);
cbean.setFile(file.getBytes());
ProductModel model = new ProductModel();
try {
BeanUtils.copyProperties(model, cbean);
eworldservice.addproduct(model);
} catch(Exception ex) {
ex.printStackTrace();
}
return new ModelAndView("home");
}
https://stackoverflow.com/questions/24805116
复制相似问题