日期:2014-05-17 浏览次数:20714 次
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //String path = req.getContextPath() + "/"; String basePath = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort(); /** 登录 */ String username = req.getParameter("username"); String password = req.getParameter("password"); String yzcode = req.getParameter("yzcode"); if ("".equals(username) || username == null || "".equals(password) || password == null) { req.getSession().setAttribute("error", "用户名或密码不能为空!"); //req.getRequestDispatcher("/login.jsp").forward(req, resp); resp.sendRedirect(basePath + "/login.html"); return; }
<% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; String error = (String) request.getSession().getAttribute("error"); String show = ""; if (error == null) error = " "; else show = "khkmsg.show('errorContent','"+error+"',false)"; request.getSession().removeAttribute("error"); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> ...(以下都是HTML标签了)