【问题标题】:spring multipart resolver configuration issue using groovy config使用 groovy 配置的 spring 多部分解析器配置问题
【发布时间】:2014-11-12 06:56:55
【问题描述】:

我有一个用于处理多部分请求的弹簧控制器。

@RestController
@RequestMapping("/file/fileStoreService")
class FileStoreService {

    @Autowired
    FileSystemStore fileSystemStore

    @RequestMapping(value = "", method = RequestMethod.POST)
    String saveOrUpdate(@RequestParam(value="data",required = false) String jsonData, @RequestParam(value="file",required =false) MultipartFile file) {


        println 'data '+jsonData
        println file

        Map data = new Gson().fromJson(jsonData, HashMap)
        String filestore = data.remove('filestore')

        fileSystemStore.saveOrUpdate(data, filestore, file)
        fileSystemStore.createFileChangelogs(data, filestore)

        return ''
    }


}

我已经在我的 appContext.groovy 中配置了 multiPartResolver bean。(我使用 groovy 进行配置)如下

mvc.'annotation-driven'()
    multiPartResolver(CommonsMultipartResolver){
        maxUploadSize=500
    }

但是当我尝试向控制器提交多部分请求时,它仍然抱怨 multipartResolver 未配置为

预期的 MultipartHttpServletRequest:是一个 MultipartResolver 配置好了吗?

我在这里遗漏了什么吗?我没有找到任何关于如何使用 groovy config 配置 multipartResolver 的示例。 提前致谢。

【问题讨论】:

    标签: spring spring-mvc groovy


    【解决方案1】:

    糟糕,bean id 定义中有错字。

    应该是 multipartResolver 而不是 multiPartResolver

    解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-20
      • 2011-09-25
      • 2018-12-26
      相关资源
      最近更新 更多