Я добился этого с помощью сеанса весенней загрузки. Надеюсь, он кому-нибудь поможет.
HTML-КОД
<form method="post" id="complainForm" action="http://localhost:8882/aalcomplaint/api/complaint/lodge-complaint" target="_blank">
<!-- you can build your own json string as you like-->
<input type="hidden" name="complainData" value='{"policyNumber":"1234", "firstName":"aa" , "lastName" : "mm"}' />
<input type="submit" id="LodgeComplain" name="LodgeComplain" value="Lodge Complain"/>
</form>
КОД ПРУЖИННОЙ ЗАГРУЗКИ
@Slf4j
@CrossOrigin(origins = "*")
@RestController
@TamAuthentication
public class ComplainsController {
@PostMapping(value = "/aalcomplaint/api/complaint/lodge-complaint")
public ModelAndView lodgeComplaint(@RequestBody String complainData, ModelAndView modelAndView, final HttpServletRequest request) {
final String id = UUID.randomUUID().toString();
try {
final ComplaintDto complaintDto = convertRequestDataToObject(complainData);
request.getSession().setAttribute(id, complaintDto);
}
catch (IOException e) {
log.error(e.getMessage());
}
modelAndView.setViewName("redirect:/#/lodge-complain?id=" + id);
return modelAndView;
}
@GetMapping(value = "/aalcomplaint/api/complaint/get-data/{id}")
public ComplaintDto getData(@PathVariable String id, final HttpServletRequest request) {
//TODO: id not null & empty check
final ComplaintDto complaintDto = (ComplaintDto) request.getSession().getAttribute(id);
request.getSession().removeAttribute(id);
return complaintDto;
}
private ComplaintDto convertRequestDataToObject(String complainData) throws IOException {
final ObjectMapper mapper = new ObjectMapper();
complainData = URLDecoder.decode(complainData, "UTF-8");
log.info("complainData > " + complainData);
return mapper.readValue(complainData.split("=")[1], ComplaintDto.class);
}
}
УГЛОВОЙКОД
export class LodgeComplainComponent {
complainDto: ComplainDto;
id : string;
constructor(private activatedRoute: ActivatedRoute, private http: HttpClient, private refService: RefService) {
this.complainDto = new ComplainDto();
}
ngOnInit() {
this.activatedRoute.queryParams.subscribe(params => {
this.id = params['id'];
console.log('id - ' + params['id']);
});
this.refService.getData(this.id).subscribe(result => {
this.complainDto = result;
});
}
}