首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法使用MyEclipse集成开发环境将图像和文件存储和检索到spring mvc中的数据库

无法使用MyEclipse集成开发环境将图像和文件存储和检索到spring mvc中的数据库
EN

Stack Overflow用户
提问于 2014-07-17 21:36:03
回答 1查看 37关注 0票数 0

我正在做一个使用spring mvc和MyEclipse集成开发环境的实时项目,没有集成maven,我的问题是如何在数据库中存储和检索图像和文件。

EN

回答 1

Stack Overflow用户

发布于 2014-07-17 23:53:28

用于在数据库中存储图像文件的控制器代码:

代码语言:javascript
运行
复制
@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");
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24805116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档