0
그래서 web.xml이 아닌 어노테이션을 사용하고 있습니다. 이 (매우 간단한 양식에 사용자 유형 FooUser 및 FooLast, 그것을 위해 welcome.jsp서블릿은 WEB-INF 내의 .jsp 파일에 액세스 할 수 없습니다.
보여줍니다 경우처럼 내 서블릿은 그렇지 않으면 같은 페이지의 login.jsp.
@WebServlet("/ServletLogin")
public class ServletLogin extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if(request.getParameter("Username").equals("FooUser") && request.getParameter("Lastname").equals("FooLast")) {
RequestDispatcher rd=request.getRequestDispatcher("/WEB-INF/Welcome.jsp");
rd.forward(request,response);
}
else {
RequestDispatcher rd=request.getRequestDispatcher("Login.jsp");
rd.forward(request,response);
}
}
}
그리고 내 로그인 리디렉션 보인다. JSP는이
<!DOCTYPE html>
<html lang="en">
<body class="login">
<div>
<form action="ServletLogin" method="post">
<h1>Login Form</h1>
<div>
<input type="text" class="form-control" placeholder="Username"
name="Username" required="" />
</div>
<div>
<input type="password" class="form-control" placeholder="Password"
name="Password" required="" />
</div>
<div>
<input class="btn btn-info" type="submit" value="Log in" />
</div>
</form>
</div>
</div>
</div>
</body>
</html>