您的位置:首页 > 其它

星期天写了点蛋疼的东西(1)

2012-08-15 14:31 489 查看
什么也不说了,相对简单,直接上代码
package org.J.v;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.J.c.Action;

/**
* 1.普通返回指向页面 ([a-zA-Z]|$)+ extends 转发
* 2.重定向 r:([a-zA-Z]|$)+ r:/([a-zA-Z]|$)+
* 3.转发 d:([a-zA-Z]|$)+ d:/([a-zA-Z]|$)+
* r:redirect 重定向 response.sendRedirect(view);
* r(1)> return 'r:action1'
* r(2)> return 'r:/action1'
* d:dispatcher request.getRequestDispatcher(view).forward(request,response);
* d(1)> return 'd:action1' 指向本命名空间下的action1
* d(2)> return 'd:/test/action2' 指向命名空间根目录的action2
*
* @author Gelopa
*
*/
public abstract class View{

/**返回path*/
protected String view;
protected transient HttpServletRequest request;
protected transient HttpServletResponse response;

protected Action actionInstance;
protected File file;//具体展现的物理文件
protected Object actionResultObj;//action返回值对象

protected static final String gen="/";//根目录
protected static final String r$normal="([a-zA-Z]|$)+";
protected static final String r$redirectThisNamespace="r:([a-zA-Z]|$)+";
protected static final String r$redirectOtherNamespace="r:/([a-zA-Z]|$)+";
protected static final String d$dispatcherThisNamespace="d:([a-zA-Z]|$)+";
protected static final String d$dispatcherOtherNamespace="d:/([a-zA-Z]|$)+";

public abstract void render();
public abstract View handlerAfterAction();

public View(){}
public View(String view, HttpServletRequest request,HttpServletResponse response) {
this.view = view;
this.request = request;
this.response = response;
}

public String getView() {
return view;
}

public void setView(String view) {
this.view = view;
}

private Map<String,Object> dataInSession=new HashMap<String, Object>();

public Map<String, Object> getAttrsInSession() {
return dataInSession;
}

public void addDataInSession(String attr,Object value){
dataInSession.put(attr, value);
}
public void delDataInSession(String attr,Object value){
dataInSession.remove(attr);
}
public Action getActionInstance() {
return actionInstance;
}
public void setActionInstance(Action actionInstance) {
this.actionInstance = actionInstance;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  view