0

I have a spring boot application whose url is localhost:8081/Zelda but when I do localhost:8081/Zelda/, I get whitelabel error

Error

I want both url to work.

index.jsp

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Zelda</title> </head> <body> <%-- <form:form method="post" action="${pageContext.request.contextPath}/login" modelAttribute="login"> --%> <form:form method="post" action="/Zelda/login" modelAttribute="login"> Name<form:input path="name" /> <br> Password<form:password path="password" /> <br> <input type="submit" name="submit" value="Submit" /> </form:form> </body> </html>

My controller code

IndexController.java

@Controller public class IndexController {

@Autowired
LoginService loginService;

@RequestMapping(value = {"/","/login"})
public String getIndex(@ModelAttribute("login") LoginModel loginModel) {
    return "index";
}

@RequestMapping(value = "/login", method = RequestMethod.POST)
public String doLogin(@ModelAttribute LoginModel loginModel, Model model) {
    TblUser user = loginService.doLogin(loginModel);
    model.addAttribute("login", user);
    return "abc";
}

}

NewBee Developer
  • 432
  • 2
  • 9
  • 26

0 Answers0