我有我的项目SpringBoot 1.5.1 gradle。Spring控制器被调用2次
我需要用“OK”或其他一些状态来回应pdf文件。
所以问题是当我用“邮差”代码调用2次时。 当我请求“卷曲”代码调用1次。
显然我想调用它1次。
我有一个应用程序类:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
我与控制器:
@RequestMapping(value = "/report/{reportTemplate:.+}", method = POST)
@ResponseBody
public ResponseEntity createReport(HttpEntity<List<ParametersEntity>> httpEntity,
@PathVariable String reportTemplate) throws IOException {
byte[] data = ...;// my data
return ResponseEntity
.ok()
.contentLength(data.length)
.contentType(MediaType.APPLICATION_PDF)
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=output.pdf")
.contentType(MediaType.parseMediaType(MediaType.APPLICATION_PDF_VALUE))
.body(data);
}
createReport
是@RestController
类。
我也有application.properties
文件在我的src/main /资源/
server.port: 10500
management.port: 10501
management.address: 127.0.0.1
什么是您的邮差版本?这似乎是一个已知的问题。 –