Problems with combo-box that sends jsp of closing session

0

I wanted to see if they could help me, what happens is that I do not want to be redirected to the combobox when the session has finished but that of "Ups A problem has occurred etc ..." I painted it on the whole screen, somehow of being able to do it the time I have it in 1 minute and this is the code that I have that is responsible for a certain time the session ends,

1 // in the XML

I hope and you can give me some idea of how I could correct this problem

Greetings to all cordial

This method is the one that makes the query in the controller and returns it in a .jsp called error, and that same one is painted in the combo-box and that I do not want to be shown that way

@RequestMapping({"/obtieneGrupos.do"}) public String obtieneGrupos(HttpServletRequest request, @ModelAttribute AmbienteTO ambienteIN, @ModelAttribute GuiaTO guiaIN, ModelMap modelMap) { 
        HttpSession session = request.getSession(false); if(session == null || session.getAttribute("usuarioTO") == null){
ExceptionTO mensajeErrorTO = new ExceptionTO(); mensajeErrorTO.setMensaje("La sesión ha terminado. Vuelva ingresar al sistema por favor");

        modelMap.addAttribute("mensajeErrorTO", mensajeErrorTO);
        return "comunes/error";             
    }

This is the view, and a function that calls it is used:

function seleccionaGuia(valor) { realizaPost('./obtieneGrupos.do', '#recordsFrm', '#cargaGrupos', 'cargaGrupos'); }

This is a generic function that causes you to load the information that previously appears a Spinner:

function realizaPost(url, idForm, divResult, idLoadingTarget) {

var spinner = loading(idLoadingTarget);
if(idForm != null) {

    $.post(url, $(idForm).serialize(), function(data){

        //alert(data.indexOf("La sesión ha terminado"));
// if(data.indexOf("La sesión ha terminado") != -1) { //
// $("#divPrincipal").empty().append(data); //
// } else {

            //SUCCESS
             $(divResult).empty().append(data);
             stopLoading(spinner);

        //}

    }).fail(function() {
        //FAIL

    });


} else {
    $.post(url, function(data){         
        $(divResult).empty().append(data);
        stopLoading(spinner);
    });
}
}

You tell me if you need another one I can provide and I gladly put it ... Regards

    
asked by cratus666jose 08.12.2016 в 23:11
source

1 answer

0

This was how I solved the problem, I hope and many will serve, Regards             // This validation serves so that the result is not painted where the Spinner is displayed, that is, it is displayed on the whole screen             // and paint the result in the DivPrincipal

        if(data.indexOf("n ha terminado") != -1) {
            $("#divPrincipal").empty().append(data);
            stopLoading(spinner);

        } else {

            //SUCCESS
             $(divResult).empty().append(data);
             stopLoading(spinner);

        }

The program could not find this string "n has finished" Only what was before the "n" was deleted

    
answered by 13.12.2016 / 01:26
source