步骤 1 : 拓扑图点亮 步骤 2 : javaweb 配置 Filter 步骤 3 : PfmFilter 步骤 4 : URLFilter 步骤 5 : web.xml 步骤 6 : 比较可运行项目,快速定位问题
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.javaweb;
import java.io.IOException;
import java.util.Enumeration;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
public class PfmFilter implements Filter{
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String url = request.getRequestURL().toString();
long start = System.currentTimeMillis();
filterChain.doFilter(servletRequest, servletResponse);
long end = System.currentTimeMillis();
System.out.println((end-start) + " ms elapsed on url:" +url);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println("PrmFilter 的初始化参数:");
Enumeration<String> e = filterConfig.getInitParameterNames();
while(e.hasMoreElements()){
String name = e.nextElement();
String value = filterConfig.getInitParameter(name);
System.out.println("name:" + name);
System.out.println("value:" + value);
}
}
}
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package cn.how2j.javaweb;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
public class URLFilter implements Filter{
@Override
public void destroy() {
System.out.println("URLFilter 的 destroy() 被调用");
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String url = request.getRequestURL().toString();
System.out.println("url filter:" + url);
filterChain.doFilter(servletRequest, servletResponse);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
}
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.HelloServlet</servlet-class>
<init-param>
<param-name>author</param-name>
<param-value>how2j(servlet)</param-value>
</init-param>
<init-param>
<param-name>site</param-name>
<param-value>http://how2j.cn(servlet)</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ParamServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.ParamServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ParamServlet</servlet-name>
<url-pattern>/param</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>HeaderServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.HeaderServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HeaderServlet</servlet-name>
<url-pattern>/header</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SetCookieServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.SetCookieServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SetCookieServlet</servlet-name>
<url-pattern>/setCookie</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>GetCookieServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.GetCookieServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GetCookieServlet</servlet-name>
<url-pattern>/getCookie</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SetSessionServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.SetSessionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SetSessionServlet</servlet-name>
<url-pattern>/setSession</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>GetSessionServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.GetSessionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GetSessionServlet</servlet-name>
<url-pattern>/getSession</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ClientJumpServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.ClientJumpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ClientJumpServlet</servlet-name>
<url-pattern>/jump1</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ServerJumpServlet</servlet-name>
<servlet-class>cn.how2j.javaweb.ServerJumpServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServerJumpServlet</servlet-name>
<url-pattern>/jump2</url-pattern>
</servlet-mapping>
<filter>
<filter-name>URLFilter</filter-name>
<filter-class>cn.how2j.javaweb.URLFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>URLFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>PfmFilter</filter-name>
<filter-class>cn.how2j.javaweb.PfmFilter</filter-class>
<init-param>
<param-name>author</param-name>
<param-value>how2j(filter)</param-value>
</init-param>
<init-param>
<param-name>site</param-name>
<param-value>http://how2j.cn(filter)</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PfmFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
增值内容,请先登录
自己写一个Tomcat, 几乎使用到了除开框架外的所有Java 技术,如多线程,Socket, J2EE, 反射,Log4j, JSoup, JUnit, Html 等一整套技术栈, 从无到有,循序渐进涵盖全部74个知识点,549个开发步骤, 为竞争高薪资职位加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|