急急急!求大神,怎么实现jQuery upload file 列表可编辑提交,并取编辑与文件对应存储操作?

诠释这低调 发布于 2015/09/02 12:51
阅读 577
收藏 0

目前模板上已加入两列输入框,但是提交到后台,无法对应上行中文件,如何实现点击开始上传,并绑定指向的输入框属于某个文件对应的值。后台如何对应?实现了很多方法都失败!

 @RequestMapping(value="/upload", method = RequestMethod.POST)
    public @ResponseBody Map<String, Object> upload(MultipartHttpServletRequest request, HttpServletResponse response) {
        int index = 0;//取值索引
        String[] titles = request.getParameterValues("title");
        String[] artists = request.getParameterValues("artist");
          LinkedList<FileMeta> files = new LinkedList<FileMeta>();
        Map<String, Object> map = new HashMap<String, Object>();
        Subject subject = SecurityUtils.getSubject();
        ShiroUser shiroUser = (ShiroUser)subject.getPrincipal();
        if(shiroUser == null){
            map.put(FILES_KEY, files);
            return map;
        }
        //1. build an iterator
        Iterator<String> itr =  request.getFileNames();
        MultipartFile mpf = null;
        //2. get each file
        while(itr.hasNext()){
            //2.1 get next MultipartFile
            mpf = request.getFile(itr.next());
//          System.out.println(mpf.getOriginalFilename() +" uploaded! "+files.size());
 
            //2.2 if files > 10 remove the first from the list
            if(files.size() >= 10)
                files.pop();
 
            String title = titles[index]; --  如果列表上有多条,jQuery upload file 则发多条请求后台方法,所以index只会取第一条数据
            String artist = artists[index];

............


加载中
返回顶部
顶部