我有我的項目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
什麼是您的郵差版本?這似乎是一個已知的問題。 –