I have the / main route, which when prompted redirects to an html page. The url is correct but is not loading anything, it remains on the login page.
This route is accessed when the user logs in to the system, in case it is the home page after login.
I wanted to understand why it does not work ....
My code is this:
/* Configuração de rotas */
app.config(function($routeProvider) {
$routeProvider.when('/main', {
templateUrl : 'views/public/main.html'
})
});
In the main.html page, you have the div with ng-view and the required javascript files being imported.
<div ng-view></div>
The java backend is responsible for redirecting to the main page after login is done.
Follow the 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();
}