How to process a multipart request consisting of a file and a JSON object in Spring restful service?

前端 未结 9 1200
一生所求
一生所求 2020-12-08 07:47

I have the following resource (implemented using Spring 4.05.RELEASE) which accepts a file and a JSON object:

(P.S. activityTemplate is a serializable entity class)<

9条回答
  •  爱一瞬间的悲伤
    2020-12-08 08:21

    The default content type is 'application/octet-stream'. Since you are uploading jar file and JSON the content type should be set in the @RequestMapping annotation as follows:

    @RequestMapping(value="/create", method=RequestMethod.POST, headers="content-type=application/json,application/java-archive")
    

提交回复
热议问题