日期:2014-05-17 浏览次数:20761 次
package ser; import impl.AccountImpl; import it.shopping.dao.IAccount; import it.shopping.pojo.Account; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class AccountSer extends HttpServlet { private IAccount accountImpl = new AccountImpl(); private static final long serialVersionUID = -3708568559174453120L; public AccountSer() { super(); } public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String status = request.getParameter("status"); if(status.equals("login")) { Account account = new Account(); account.setAlogin(request.getParameter("alogin")); account.setApass(request.getParameter("apass")); account =accountImpl.queryAccount(account); if(account == null) { request.setAttribute("error", "登录失败"); request.getRequestDispatcher("/alogin.jsp").forward(request, response); // response.sendRedirect("alogin.jsp"); } { request.getSession().setAttribute("account", account); // response.sendRedirect("/t31/admin/index.jsp"); // 重定向和请求装啊session值都不会失效! request.getRequestDispatcher("/admin/index.jsp").forward(request, response); } } } public void init() throws ServletException { // Put your code here } }
package ser; import impl.CategoryImpl; import it.shopping.dao.ICategory; import it.shopping.pojo.Account; import it.shopping.pojo.Category; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CategorySer extends HttpServlet { private ICategory categoryImpl = new CategoryImpl(); public void destroy() { supe