struts的功能就是根据用户访问不同的url,把请求分发给相应的action类处理。实现了MVC架构中的V,C分离
public class FileUploadAction extends ActionSupport implements ServletContextAware { public String execute() throws Exception { System.out.println("execute"); return this.SUCCESS; } }
拦截器统计action执行时间
public class MyInterceptor extends AbstractInterceptor { public String intercept(ActionInvocation invocation) throws Exception { long startTime = System.currentTimeMillis(); String result = invocation.invoke();// 调用下一个拦截器,如果没有其他拦截器则调用action long endTime = System.currentTimeMillis(); System.out.println("Action执行共需要" + (endTime - startTime) + "毫秒"); return result; } }