日期:2014-05-20 浏览次数:20658 次
<html> <head> <title>测试doGet</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <form action="/doget_servlet" method="get"> <table><tr><td>输入名称后提交:<input type="text" name="name"> </td></tr> <tr><td><input type="submit" name="submit" value="确定"></td></tr> </table> </form> </body> </html>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" version="2.4"> <display-name>Welcome to Tomcat</display-name> <description> JSP </description> <servlet> <servlet-name>DoGetTestServlet</servlet-name> <servlet-class>classes.DoGetTestServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>DoGetTestServlet</servlet-name> <url-pattern>/doget_servlet</url-pattern> </servlet-mapping> </web-app>
public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LoginForm f = (LoginForm)form; if(ils.login(f.getUsername(), f.getPassword())) { request.setAttribute("fail", "恭喜您,登录成功!"); return mapping.findForward("index"); } else { request.setAttribute("fail", "对不起,登录失败!"); return mapping.findForward("login"); } }