一、web.xml
//设置会话过期时间,这里单位是分钟
<session-config>
<session-timeout>30</session-timeout> </session-config>
//过滤器
<filter>
<filter-name>IllegalFilter</filter-name> <filter-class>com.dengfeng.IllegalFilter</filter-class> <init-param> <param-name>START-UP</param-name> <param-value>1</param-value> </init-param> </filter> <filter-mapping> <filter-name>IllegalFilter</filter-name> <url-pattern>/*</url-pattern> <!--/*表示对所有请求进行拦截--> </filter-mapping>
//监听器
<listener>
<listener-class>com.dengfeng.SessionListener</listener-class> </listener> <listener> <listener-class>com.dengfeng.OnlineUserListener</listener-class> </listener>
//servlet配置
<servlet>
<servlet-name>FileUpload</servlet-name> <servlet-class>com.deng.FileUpload</servlet-class> </servlet> <servlet-mapping> <servlet-name>FileUploadd</servlet-name>//这个地方如果是写路径表示前端请求交给servlet-name对应的servlet-class处理,如果是写*.do,表示所有的请求交个servlet处理
<url-pattern>/deng/FileUpload</url-pattern> </servlet-mapping>