0

私は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();
}
4

1 に答える 1