<%@ page contentType="text/html; charset=GBK" language="java"%> <%@taglib prefix="s" uri="/struts-tags"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; c…
Listener:当Web应用在Web容器中运行时,Web应用内部会不断地发生各种事件,如Web应用被启动.Web应用被停止,用户Session开始,用户session结束.用户请求到达等,这些对Web事件对开发者是透明的. ServletAPI提供了大量的监听器来监听Web应用的内部事件,从而允许当Web内部事件发生时回调事件监听器内的方法. 使用步骤:定义Listener实现类 通过Annotation或在web.xml文件中配置Listener. 常用Listener类: ServletC…
package sanglp.servlet; import javax.servlet.*; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletRequest; import java.io.IOException; /** * Created by Administrator on 2016/10/5. */ @WebFilter(filterName = "log", u…
package sanglp; import com.opensymphony.xwork2.*; /** * Created by Administrator on 2016/10/6. */ public class LoginAction implements com.opensymphony.xwork2.Action { //定义封装请求参数的username和password属性 private String username; private String password; //…
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <!--struts是Struts2配置文件的…
<%-- login.jsp Created by IntelliJ IDEA. User: Administrator Date: 2016/10/6 Time: 16:26 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> &…
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2016/10/6 Time: 16:26 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@tagli…
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2016/10/6 Time: 14:20 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html>…
package sanglp.servlet; import javax.servlet.ServletContext; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import java.util.Hashtable; import java.util.Map; /** * Creat…
package sanglp.servlet; import javax.servlet.*; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpServletRequest; /** * Created by Administrator on 2016/10/5. */ @WebListener public class RequestListener implements ServletReq…