我有一个生成 sql 文件的应用程序,我的问题是当我尝试下载文件并且请求中有重音时,我得到以下结果:
delete from gfe_param_fa where parfa_ident=9 and parfa_code_doc='ANNEXEC17' and parfa_libelle_doc='Dde certificat d''hérédité' and parfa_interaction='NON' and parfa_identifiant='POLICE' and parfa_remise='LETTRE' and parfa_application='ANNEXE_CO' and nvl(parfa_tri1,'NULL') = 'NULL' and nvl(parfa_tri2,'NULL') = 'NULL' and nvl(parfa_tri3,'NULL') = 'NULL' and parfa_archivage='OUI' and parfa_chemise='ANNEXE_GESTION' and parfa_type_appli_au='CL' and parfa_application_cl='ANNEXE_CO' and nvl(parfa_application_au,'NULL') = 'NUL
代替
delete from gfe_param_fa where parfa_ident=9 and parfa_code_doc='ANNEXEC17' and parfa_libelle_doc='Dde certificat d''hérédité' and parfa_interaction='NON' and parfa_identifiant='POLICE' and parfa_remise='LETTRE' and parfa_application='ANNEXE_CO' and nvl(parfa_tri1,'NULL') = 'NULL' and nvl(parfa_tri2,'NULL') = 'NULL' and nvl(parfa_tri3,'NULL') = 'NULL' and parfa_archivage='OUI' and parfa_chemise='ANNEXE_GESTION' and parfa_type_appli_au='CL' and parfa_application_cl='ANNEXE_CO' and nvl(parfa_application_au,'NULL') = 'NULL';
我已将问题的原因与口音隔离开来;只要请求中没有重音,它就不会发生。
这是我的下载功能:
public void download(String request) throws IOException {
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
BufferedInputStream input = null;
BufferedOutputStream output = null;
try {
input = new BufferedInputStream(new ByteArrayInputStream(
request.getBytes()), DEFAULT_BUFFER_SIZE);
ec.responseReset();
ec.setResponseContentType("application/sql");
ec.setResponseContentLength(request.length());
ec.setResponseHeader("Content-Disposition",
"attachment; filename=\"" + "update.sql" + "\"");
ec.setResponseHeader("Refresh", "1; url = main.xhtml");
output = new BufferedOutputStream(ec.getResponseOutputStream(),
DEFAULT_BUFFER_SIZE);
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int length;
while ((length = input.read(buffer)) > 0) {
output.write(buffer, 0, length);
}
output.flush();
} finally {
close(output);
close(input);
}
fc.responseComplete();
}