Spring学习笔记(1)----将Spring与Servlet整合(二)

2014-11-24 10:18:54 · 作者: · 浏览: 1
ws ServletException {
// TODO Auto-generatedmethod stub
super.init(config);
applicationContext=WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
userAccount=(UserAccount) applicationContext.getBean("userAccount");
}

/**
* @seeHttpServlet#service(HttpServletRequest request, HttpServletResponse response)
*/
protected void service(HttpServletRequest request, HttpServletResponseresponse) throws ServletException, IOException {
// TODO Auto-generatedmethod stub
String account=request.getParameter("account");
String password=request.getParameter("password");
System.out.println(account+":"+password);
if(userAccount.checkAccount(account, password)){
response.sendRedirect("success.jsp account="+account);
}else{
response.sendRedirect("fail.jsp");
}
}

}



效果如下图所示:


\