I have a problem with this web service code
@Controller @RequestMapping("/u_tutorial") public class UploadTutorial { @RequestMapping(value = "tutorial1", method = RequestMethod.POST, headers = "Accept=application/json") @ResponseStatus(value = HttpStatus.OK) public void upload(@RequestBody String body, @RequestParam List<MultipartFile> file, Principal principal, HttpServletRequest request) { System.out.println("body: " + body);
The situation is when I want to upload files with some data to the request body, my body variable always gives me an empty string.
But when I try to use only the "body of the string @RequestBody" or the "list file @RequestParam", it works like a charm.
I did a few searches and found that this was due to the InputStream problem. Some proposed solution has already been discussed, but is not entirely related to my problem (or maybe yes, but I do not understand).
Can someone give me a solution? thanks.
PS 1. here is my version of the library
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.core.version>3.1.4.RELEASE</spring.core.version> <spring.security.version>3.1.3.RELEASE</spring.security.version> <spring.data.mongodb.version>1.1.0.RELEASE</spring.data.mongodb.version> <cglib.version>2.2</cglib.version> <aspectj.version>1.6.10</aspectj.version> <mongodb.driver.version>2.10.1</mongodb.driver.version> <slf4j.version>1.6.1</slf4j.version> <log4j.version>1.2.14</log4j.version> <javax.jstl-taglibs.version>1.1.2</javax.jstl-taglibs.version> <jackson.version>1.9.3</jackson.version> <mockito.version>1.8.5</mockito.version> <junit.version>4.8.2</junit.version> <maven.copy.plugin.version>0.2.3</maven.copy.plugin.version> <maven.compiler.plugin.version>2.3.2</maven.compiler.plugin.version> <maven.apt.plugin.version>1.0</maven.apt.plugin.version> <apache.common.io.version>2.4</apache.common.io.version> <apache.common.fileupload.version>1.2.2</apache.common.fileupload.version> <jodatime.version>2.1</jodatime.version> </properties>
PS 2. Sorry for my English.
source share