Java 执行时出错";邮政「;春季手术?
我已经从角度服务类发送了数据。在这里我已经发送了三个参数的信,文件,empList到Api进行后期操作Java 执行时出错";邮政「;春季手术?,java,spring,angular,spring-boot,angular6,Java,Spring,Angular,Spring Boot,Angular6,我已经从角度服务类发送了数据。在这里我已经发送了三个参数的信,文件,empList到Api进行后期操作 export class LetterService { private baseUrl = 'http://localhost:8080/api/letter'; constructor(private http: HttpClient) { } saveThree(letter: Object,documents: Object,empList: Object): Ob
export class LetterService {
private baseUrl = 'http://localhost:8080/api/letter';
constructor(private http: HttpClient) { }
saveThree(letter: Object,documents: Object,empList: Object): Observable<Object> {
return this.http.post(`${this.baseUrl}` + `/create`, {letter,documents,empList});
}
export-class-LetterService{
专用baseUrlhttp://localhost:8080/api/letter';
构造函数(私有http:HttpClient){}
saveThree(字母:Object,文档:Object,雇员:Object):可观察{
返回this.http.post(`${this.baseUrl}`+`/create`,{letter,documents,empList});
}
在Spring引导端,我使用@RequestBody映射来自服务的JSON数据(您可以省略代码的内部逻辑,因为错误是另一回事):
@PostMapping(value=“/letter/create”)
公共字符串postAllThree(@RequestBody lettedto lettedto,
@RequestBody列表文档,@RequestBody SelectionCustomOfficeTo SelectionCustomOfficeTo){
ClkLetter ClkLetter=clkLetterRepository.findById((long)1.get();
Selection=selectionRepository.findById((长)lettedto.getSelectionNo()).get();
Assessment Assessment=assessmentRepository.findById((长)lettedto.getAssessmentNo()).get();
Letter Letter=letterRepository.save(新字母(clkLetter,lettedto.getInOut(),lettedto.getInOutNo(),lettedto.getInOutDate(),lettedto.getLetterIssuedSubBy(),lettedto.getletlettlefile(),lettedto.getRepresentativeName())
选择,评估),;
用于(文档文档:文档){
如果(docume.isChecked()){
letterDocRepository.save(新的LetterDoc(字母,文档,“a”));
}
}
返回“成功”;
}
我得到的错误是:
[org.springframework.http.converter.httpMessageNodeTableException:读取输入消息时发生I/O错误;嵌套异常为java.io.IOException:流已关闭]
为什么会出现此错误?我从angular发送的参数不匹配,或者@Postmapping操作中有任何错误?我也看到了其他文章和问题,但它不起作用。您只能有一个@RequestBody。将{letter,documents,empList}合并到一个DTO POJO中
public class MyDTO {
private Object letter;
private List<Object> documents;
private List<Object> empList;
// getters and setters
}
公共类MyDTO{
私人宾语字母;
私人清单文件;
私人名单雇主;
//接球手和接球手
}
对于基元类型请求参数,您可以使用@RequestParam并将它们附加到URL中。您只允许有一个@RequestBody。将{letter,documents,empList}组合到一个DTO POJO中
public class MyDTO {
private Object letter;
private List<Object> documents;
private List<Object> empList;
// getters and setters
}
公共类MyDTO{
私人宾语字母;
私人清单文件;
私人名单雇主;
//接球手和接球手
}
对于基元类型请求参数,您可以使用@RequestParam并将它们附加到URL中