简体   繁体   中英

my response.sendRedirect(); is not working

I'm trying to redirect a new page with this syntax

try {
        usuarios usu = new usuarios();
        usu.setNombreusuario(request.getParameter("parCodigo"));
        System.out.println(usu.getUsuario());
        usu.setContrasena(request.getParameter("parContrasenha"));
        System.out.println(usu.getContrasena());
        usu = usuariosDAO.login(usu);
        System.out.println("es valido? " + usu.isValid());
        if (usu.isValid()) {
            HttpSession session = request.getSession(true);
            session.setAttribute("usuario", usu.getUsuario());
            response.sendRedirect("/KolaEscocesaCRM/menumobile.jsp");
            return;
        } else {
            response.sendRedirect("/KolaEscocesaCRM/loginmobile.jsp");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

My problem is that when I submit I get this:

http://localhost:8084/KolaEscocesaCRM/srvMenu2?parCodigo=admin&parContrasenha=kola

I don't know what to do please any help would be fine

If you get a dear 404

Most of the time, because the entry application is mapped into something like /myapp instead of / (root)

The server says to the browser go to /KolaEscocesaCRM/loginmobile.jsp where it should be /.myapp/KolaEscocesaCRM/loginmobile.jsp

The simplest way is changing the context-path to root ( / or empty string)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM