0
I have the /main route, which when prompted redirects to an html page. The url is correct, but is not loading anything, remains on the login page.
This route is accessed when the user logs in to the system, in this case it is the home page after the login.
I wanted to understand why it doesn’t work....
My code is this:
/* Configuração de rotas */
app.config(function($routeProvider) {
$routeProvider.when('/main', {
templateUrl : 'views/public/main.html'
})
});
On the main.html page, you have the div with ng-view and the required javascript files being imported.
<div ng-view></div>
The java back-end is responsible for redirecting to the main page, after the login is performed.
Follows java code:
private String process(HttpServletRequest request, HttpServletResponse response) throws SQLException{
String context = request.getServletContext().getContextPath();
User user = new UserDAO().doLogin(request.getParameter("mail"), request.getParameter("password"));
JSONObject msg = new JSONObject();
try {
HttpSession sessao = request.getSession();
if (user != null) {
sessao.setAttribute("user", user);
response.sendRedirect(context + "/main");
} else {
msg.put("msg", "Erro ao logar");
sessao.setAttribute("msg", "Usuario ou senha invalido!");
response.sendRedirect(context + "/index.html?login=invalid");
}
} catch (Exception e) {
e.printStackTrace();
}
return msg.toString();
}
Giovane tried here and it didn’t work anyway. The url looks like this: http://localhost:8080/Odonto/#! /main .
– Guilherme Nass