Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'message': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (io.netty.buffer.ByteBufInputStream); line: 1, column: 9]
Stack trace:
at org.springframework.http.codec.json.AbstractJackson2Decoder.processException(AbstractJackson2Decoder.java:242) ~[spring-web-5.3.12.jar:5.3.12]
at org.springframework.http.codec.json.AbstractJackson2Decoder.decode(AbstractJackson2Decoder.java:198) ~[spring-web-5.3.12.jar:5.3.12]
at org.springframework.http.codec.json.AbstractJackson2Decoder.lambda$decodeToMono$1(AbstractJackson2Decoder.java:179) ~[spring-web-5.3.12.jar:5.3.12]
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:295) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:159) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:260) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142) ~[reactor-core-3.4.11.jar:3.4.11]
at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400) ~[reactor-netty-core-1.0.12.jar:1.0.12]
at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419) ~[reactor-netty-core-1.0.12.jar:1.0.12]
at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473) ~[reactor-netty-core-1.0.12.jar:1.0.12]
at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:702) ~[reactor-netty-http-1.0.12.jar:1.0.12]
{
"message": "string",
"originator": "string",
"receivers": "string"
}
@Override
public Mono<ResponseEntity<? extends ResponseResource>> sendSms(BulkSmsRequestResourceTest request) {
if (request == null) {
return Mono.just(new ResponseEntity<>(
new ErrorResponseResource(
"Transaction failed unsuccessfully!",
400),
HttpStatus.BAD_REQUEST));
}
Mono<BulkSmsRequestResourceTest> bulkSmsRequestResourceMono = webClientBuilder.build()
.post()
.uri(sendSmsService)
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.body(Mono.just(request), BulkSmsRequestResourceTest.class)
.retrieve()
.bodyToMono(BulkSmsRequestResourceTest.class);
bulkSmsRequestResourceMono.subscribe();
return Mono.just((new ResponseEntity<>(new SuccessResponseResource("Transaction done successfully", 200), HttpStatus.OK)));
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BulkSmsRequestResourceTest {
@JsonProperty("message")
private String message;
@JsonProperty("receivers")
private String receivers;
@JsonProperty("originator")
private String originator;
}
@Override
public String save(BulkSmsRequestDto bulkSmsRequestDto) {
if (bulkSmsRequestDto == null) {
return "message unsuccess sended";
}
BulkSms bulkSms = BulkSms.builder()
.message(bulkSmsRequestDto.getMessage())
.phoneNumber(bulkSmsRequestDto.getReceivers())
.originator(bulkSmsRequestDto.getOriginator())
.build();
this.bulkSmsRepository.save(bulkSms);
return "message success sended";
}
在我看来,您发送的消息
属性根本不是您所调用的服务所期望的。
您将BulksMsRequestResourceTest
设置为正文请求和正文响应。您确定服务器需要在请求中包含message
属性,并在响应中包含message
吗?
您的附加代码只是显示了这一点。您的服务器使用一个简单的字符串
(“Message success Sended”)进行应答,但您希望它是一个对象(BulksMsRequestResourceTest
)。请将您的代码更新为以下代码:
@Override
public Mono<ResponseEntity<? extends ResponseResource>> sendSms(BulkSmsRequestResourceTest request) {
if (request == null) {
return Mono.just(new ResponseEntity<>(
new ErrorResponseResource(
"Transaction failed unsuccessfully!",
400),
HttpStatus.BAD_REQUEST));
}
Mono<String> bulkSmsRequestResourceMono = webClientBuilder.build()
.post()
.uri(sendSmsService)
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.body(Mono.just(request), BulkSmsRequestResourceTest.class)
.retrieve()
.bodyToMono(String.class);
bulkSmsRequestResourceMono.subscribe();
return Mono.just((new ResponseEntity<>(new SuccessResponseResource("Transaction done successfully", 200), HttpStatus.OK)));
}
我有问题发送React多部分表单数据到后端MySQL使用Java。当我在Postman中分别测试React和Java时,它工作得很好。当我使用表单将用户数据和图片从前端发送到后端时,我会出现无法识别的令牌错误。我对这个错误研究了很多,似乎找不到解决办法。请帮助我哪里出了问题。
我创建了非常简单的流程,我已经附上了下面的图片。 流程描述: 用户发送费用报告,最后它得到审查,应该批准,而我是点击批准按钮。但我得到了如下错误: 变量上的当前json 请问json中的错误是什么,我在名为“onaccept1”的变量上犯了什么错误。
和ContactForm 我不知道到底发生了什么,因为如果我尝试向控制器发送一个带有POSTMAN的JSON,这个主体与相同,一切都很顺利,所以Jackson在幕后做了一些奇怪的事情...
我有一个模型 但我有个错误 有什么想法可以修复这个错误吗?