SpringMVC control layer receives multiple front-end parameters
Report an error I/O error while reading input message; nested exception is java.io.IOException: Stream closed
[Controller]
@PostMapping("/list")
public Result<List<ReviseInfo>> list(@RequestBody ReviseInfo reviseInfo, @RequestBody ReviseRequest reviseRequest){
return reviseAdaptor.list(reviseInfo, reviseRequest);
}
ReviseInfo
@Data
public class ReviseInfo {
/** Primary key Id */
@MongoId
private String id;
/** Manuscript Id */
private String subjectId;
/** Version Id */
private String versionId;
/** Suspected error */
private String fragOri;
/** Suggested adjustment */
private String fragFixed;
/** 1-Unprocessed 2-Ignored 3-Corrected (3 not stored in the library)*/
private Integer type;
}
ReviseRequest)
@Data
public class ReviseRequest {
/** Error correction content list */
private List<ReviseContent> data;
}
Transmission parameter
{
// Current manuscript ID
"subjectId": "5f4b7a6cc04e43398921421aef8b77a2",
// Error correction content list
"data": [
{
"content": "Ningxia's good time record plans to investigate"
}
]
}
Error I/O error while reading input message; Needed exception is java.io.ioexception: stream closed
solution
1. Create a new data transmission object, such as revisedto, and merge the required parameters into a dto
[revisedto]
@Data
public class ReviseDTO {
/** Manuscript Id */
private String subjectId;
/** Error correction content list */
private List<ReviseContent> data;
}
[Controller]
@PostMapping("/list")
public Result<List<ReviseInfo>> list(@RequestBody ReviseDTO reviseDTO){
return reviseAdaptor.list(reviseDTO);
}
2. Use map < String, Object> Receive multiple parameters
[controller]
@PostMapping("/list")
public Result<List<ReviseInfo>> list(@RequestBody Map<String, Object> params){
return reviseAdaptor.list(params);
}
[Adaptor/serviceImpl]
import org.apache.commons.collections4.MapUtils;
String subjectId = MapUtils.getString(params, "subjectId");
List<ReviseContent> data = (List<ReviseInfo>)MapUtils.getObject(params, "data");
// List<ReviseInfo> data = (List<ReviseInfo>)params.get("data");
Read More:
- Java learning unreported exception java.io.IOException ; must be caught or declared to be thrown
- Run hadoop fs -put Command Error: java.io.IOException: Got error, status message , ack with firstBadLink
- [Solved] canal Startup Error: error while reading from client socket java.io.IOException: Received error packet:
- [Solved] java.io.IOException: Got error, status=ERROR, status message, ack with firstBadLink as
- nested exception is java.lang.StackOverflowError [How to Solve]
- [Solved] Hadoop Error: Exception in thread “main“ java.io.IOException: Error opening job jar: /usr/local/hadoop-2.
- Request processing failed; nested exception is java.lang.NullPointerException or UnsatisfiedDependencyE
- [Solved] Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
- [How to Solve] Java nested object @validated is not valid
- [Solved] nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
- [Solved] ClientAbortException: java.io.IOException: Connection reset by peer
- [Solved] swagger Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullP
- [Solved] Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
- [Solved] Failed to start bean ‘eurekaAutoServiceRegistration‘; nested exception is java.lang.NullPointerExce
- [Solved] MultipartException: Failed to parse multipart servlet request; nested exception is java.lang.Runtime
- [Solved] Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPointerEx
- Error resolution: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/Datatype
- [Solved] Sqoop Error: ERROR tool.ImportTool: Import failed: java.io.IOException
- [Solved] nacos Startup Error: nested exception is java.lang.RuntimeException: java.lang.RuntimeException: [db-load-error
- keytool Error: java.io.IOException: Keystore was tampered with, or password was incorrect