我的页面打开一个新标签页,我不知道为什么

My page is opening a new tab and I don't know why

我有一个网页,当输入的日期正确时必须下载 XLS,但如果它们不正确,它必须显示一条消息并停止下载过程。

一切正常,当日期不正确时我会建议用户,但每次我单击该按钮时它都会打开一个新选项卡。如果日期正确,它会打开一个新选项卡,但在下载 XLS 时关闭,如果日期不正确,它会建议用户,但它会打开新选项卡但不会关闭它。我该如何修复它而不打开新标签页?

我把我的代码放在下面:

HTML:

        <div class="botonera">
            <a4j:commandLink id="regimenConcertadoLink"
                styleClass="botonAplicacionTXT"
                action="#{descargaInformesBean.validarInformeRegimenConcertado()}"
                oncomplete="if(#{descargaInformesBean.informeRegimenConcertadoValido}){#{rich:element('descargaInforme')}.onclick();}"
                status="waitStatus">
                <h:outputText value="Descargar Informe" />
                <h:graphicImage value="/img/ico_descargar.gif"
                    alt="Descargar Informe"
                    title="Descargar Informe" />
                <f:param name="requiredValidator"
                    value="requiredValidator" />
            </a4j:commandLink>
            <h:commandLink id="descargaInforme"
                styleClass="botonAplicacionTXT" target="_blank"
                action="#{descargaInformesBean.descargarInformeIngresos()}">
            </h:commandLink>
        </div>

JAVA:

 public void descargarInformeIngresos() throws ServiceException, IOException {        
    if ((filtroFechaDesde != null && filtroFechaHasta != null) || (filtroFechaIngresoDesde != null && filtroFechaIngresoHasta != null)) {
        //DOXMLSTUFF 
    }else {
        AtlasFacesUtils.addErrorMessageFromBundle("error.fecha.vacia");
    }
}

正如您在代码中看到的,如果两个日期都为空,我什么都不做并显示一条消息来建议用户,这工作正常,但仍然打开一个新选项卡,但我没有想这样做

谢谢!

我认为这是由于您使用的目标标记属性引起的。

target="_blank" 打开一个新标签页

尝试将其更改为

target="_self" 看看它是否修复了它。