eventhandlerbase.java

来自「MVC结构开发简单例子 非常实用的..有学习MVC的可以看看.」· Java 代码 · 共 41 行

JAVA
41
字号
package com.mvc.event.baseEvent;import java.io.IOException;import javax.servlet.RequestDispatcher;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public abstract class EventHandlerBase {  protected abstract String getURL();  public void process( HttpServletRequest request, HttpServletResponse response )    throws IOException,           ServletException{  }  public void forward( HttpServletRequest request, HttpServletResponse response )    throws IOException,           ServletException{    try{      _dispatch( request, response );    }catch( IOException i ){      throw i;    }catch( ServletException s ){      throw s;    }  }  protected void _dispatch( HttpServletRequest request, HttpServletResponse response )    throws IOException,           ServletException{    RequestDispatcher rd = request.getRequestDispatcher( getURL() );    if( rd == null ){      throw new ServletException("resource RequestDispatcher apply failed");    }    rd.forward( request, response );  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?