Я пытался отправить строку с помощью метода POST на веб-сервер SpringBoot, когда строка мала (200 КБ), она может быть получена на конце контроллера, тогда как, когда строка относительно большая (2 МБ), поле контроллера пусто без любое сообщение об ошибке в журнале SpringBoot.
Фрагмент кода контроллера:
@PostMapping(value = "/func")
public ResponseMessage func(@RequestParam(value = "message", defaultValue = "") String message) {
if(StringUtils.isEmpty(message)) {
// alert
}
}
и фрагмент кода отправителя:
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
// Create socket configuration
SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true)
.setSoTimeout(180000).setSoReuseAddress(true).setTcpNoDelay(true).build();
// Configure the connection manager to use socket configuration either
// by default or for a specific host.
connManager.setDefaultSocketConfig(socketConfig);
// Validate connections after 1 minute of inactivity
connManager.setValidateAfterInactivity(180000);
connManager.setMaxTotal(100);
connManager.setDefaultMaxPerRoute(20);
// Create global request configuration
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setCookieSpec(CookieSpecs.DEFAULT).setExpectContinueEnabled(true)
.setConnectTimeout(180000).setSocketTimeout(180000)
.setConnectionRequestTimeout(180000).build();
CloseableHttpClient hc = HttpClients.custom().setConnectionManager(connManager)
.setDefaultRequestConfig(defaultRequestConfig).setDefaultSocketConfig(socketConfig)
.build();
String encodedMsg = new String(Files.readAllBytes(Paths.get(args[0])), UTF_8);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(Lists.newArrayList(new BasicNameValuePair("message", encodedMsg)), UTF_8);
HttpUriRequest httpPost = HttpUtils.post("http://url/func", entity);
try (CloseableHttpResponse response = hc.execute(httpPost)) {
// ...
}
Я пытался добавить следующие параметры размера тела запроса в application.properties, но, похоже, он не работает. Какие-либо предложения? Спасибо.
multipart.maxRequestSize=30MB
multipart.maxFileSize=30MB
spring.http.multipart.maxFileSize=30Mb
spring.http.multipart.maxRequestSize=30Mb
SpringBoot: 1.5.10. RELEASE
Весна: 4.3.14. РЕЛИЗ