非常感謝您,先生
但我做到了,而無需使用Spring框架:)
這是我的代碼:
1 - AccountControler.java
public class AccountController extends HttpServlet {
// GET
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String action = Helper.getAction(request);
switch (action) {
case "Login":
// ToDo
View.go(request, response, "../LoginView.jsp");
break;
case "Register":
// ToDo
View.go(request, response, "../RegisterView.jsp");
break;
default:
View.go(request, response, "../HomeView.jsp");
break;
}
}
}
這是的getAction()方法
public static String getAction(HttpServletRequest request) {
String act[] = request.getRequestURL().toString().split("/");
return act[act.length-1];
}