我实际上正在开发一个项目,该项目涉及一个带有一些Flex的Adobe Flash Player Windows,它调用一个包含在spring mvc控制器中的rest服务,其目的是使用一个生成带有Jasper报告的pdf文件的服务。 / p>
以下是调用Web服务的ActionScript方法:
private function editerCourrier():void{
//Security.loadPolicyFile("http://appserv01.siege.xm:4040/Editions/RetardLivraison/crossdomain.xml");
if(this.gridActivated == "mailing"){
var request:URLRequest = new
URLRequest("http://10.102.22.143:8280/edition_sc_retards_livraisons/Export/RetardLivraisonLettre");
var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "application/json");
request.method = URLRequestMethod.POST;
request.requestHeaders.push(hdr);
var jsonArray:Array = new Array();
jsonArray.push({
"civilite" : "Mr.",
"destNom" : "TAMBE",
"destPrenom" : "JOEL",
"destAdresseFull" : "54 rue des Cocotiers",
"destCP" : "93270",
"destVille" : "ANTONY",
"nomPays" : "FRANCE",
"pjPath" : "http://192.168.200.97/intranet/e107_files/mail_attachement/MAIL_AVENANT_TEMPORAIRE_1507817106_1534679.txt"
});
request.data = jsonArray;
navigateToURL(request,"win_cour");
}
}
此外,这是其余控制器
@Api
@Controller
public class RetardLivraisonLettreControllerImpl implements RetardLivraisonLettreController {
private static Logger logger = Logger.getLogger(RetardLivraisonLettreControllerImpl.class);
private final EditionConfig editionConfig;
private final EditionService editionService;
private static final String SUCCESS = "success";
private static final String ERROR = "error";
public RetardLivraisonLettreControllerImpl(EditionConfig editionConfig, EditionService editionService) {
this.editionConfig = editionConfig;
this.editionService = editionService;
}
@RequestMapping(value = "/Export/RetardLivraisonLettre", method = RequestMethod.POST, produces = "application/pdf", consumes = {
"application/json",
"application/x-www-form-urlencoded;charset=ISO-8859-1" }, headers = "Accept=application/x-www-form-urlencoded")
@Override
public ResponseEntity<String> retardLivraisonLettre(@RequestBody RetardLivraisonLettreBean bean,
HttpServletResponse response) throws InvalidParameterException {
logger.debug("appel retardLivraisonLettre");
String nomCible = editionConfig.getNomCible();
try {
// Download du PDF
logger.debug("Download du PDF");
editionService.retardLivraisonLettre(bean, response.getOutputStream());
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=" + nomCible);
response.getWriter().close();
response.setHeader(SUCCESS, "Edition du PDF de la lettre de retard de livraison effectué avec succès");
} catch (IOException e) {
logger.error(e.getMessage(), e);
response.setHeader(ERROR, "Erreur lors de l'édition du PDF de la lettre de retard de livraison effectué");
return new ResponseEntity<String>(response.getHeader(ERROR), HttpStatus.BAD_REQUEST);
}
return new ResponseEntity<String>(response.getHeader(SUCCESS), HttpStatus.ACCEPTED);
}
}
答案 0 :(得分:0)
请求标头应命名为“Content-Type”,而不是“Content-type”。