这是我自己开发的一个MVC框架
源代码在线查看: abstractpage.java
package dark.web.frame.page;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import dark.web.frame.Helper;
import dark.web.frame.Message;
import dark.web.frame.Page;
import dark.web.frame.Value;
import org.apache.log4j.Logger;
/**
* Title: 请求页面抽象类
* Description: 定义页面处理程序所必需的接口方法和公用方法
* Copyright: Copyright (c) 2004
* Company: DIS
* Create Time: 2004-3-6 0:17:20
* @author darkhe
* @version 1.0
*/
public abstract class AbstractPage implements Page
{
protected static Logger log = Logger.getLogger("DWF");
private ServletContext servletContext;
private ServletConfig servletConfig;
private HttpServletRequest request;
private HttpServletResponse response;
private String target;
/**
* 设置初始化参数,
* @param config
* @param request
* @param response
*/
public void init(
ServletContext servletContext,
ServletConfig servletConfig,
HttpServletRequest request,
HttpServletResponse response)
{
this.servletContext = servletContext;
this.servletConfig = servletConfig;
this.request = request;
this.response = response;
}
/**
* 页面类的检证方法,default返回true,开发人员可根据具
* 体商来逻辑来重置当前方法的行为。只要当前返回true的情
* 况下,process方法才被执行
* @return
* @throws ServletException
* @throws IOException
*/
public boolean isAuthentic() throws ServletException, IOException
{
return true;
}
/**
* @throws ServletException
* @throws IOException
*/
public void forward() throws ServletException, IOException
{
RequestDispatcher dispathcer = request.getRequestDispatcher(target);
dispathcer.forward(request, response);
}
/**
* @throws ServletException
* @throws IOException
*/
public void include() throws ServletException, IOException
{
RequestDispatcher dispathcer = request.getRequestDispatcher(target);
dispathcer.include(request, response);
}
/**
* @return
*/
public HttpServletRequest getRequest()
{
return request;
}
/**
* @return
*/
public HttpServletResponse getResponse()
{
return response;
}
/**
* @return
*/
public ServletConfig getServletConfig()
{
return servletConfig;
}
/**
* @param config
*/
public void setServletConfig(ServletConfig config)
{
servletConfig = config;
}
/**
* @return
*/
public ServletContext getServletContext()
{
return servletContext;
}
/**
* @param context
*/
public void setServletContext(ServletContext context)
{
servletContext = context;
}
/**
* @param request
* @return
*/
public static Message loadMessage(HttpServletRequest request)
{
return Helper.loadMessage(request);
}
/**
* @param session
* @return
*/
public static Message loadMessage(HttpSession session)
{
return Helper.loadMessage(session);
}
/**
* @param request
* @return
*/
public static Value loadValue(HttpServletRequest request)
{
return Helper.loadValue(request);
}
/**
* @param session
* @return
*/
public static Value loadValue(HttpSession session)
{
return Helper.loadValue(session);
}
/**
* @param m
* @param request
*/
public static void saveMessage(Message m, HttpServletRequest request)
{
Helper.saveMessage(m, request);
}
/**
* @param m
* @param session
*/
public static void saveMessage(Message m, HttpSession session)
{
Helper.saveMessage(m, session);
}
/**
* @param v
* @param request
*/
public static void saveValue(Value v, HttpServletRequest request)
{
Helper.saveValue(v, request);
}
/**
* @param v
* @param session
*/
public static void saveValue(Value v, HttpSession session)
{
Helper.saveValue(v, session);
}
/**
* @return
*/
public String getTarget()
{
return target;
}
/**
* @param string
*/
public void setTarget(String string)
{
target = string;
}
}