星期天写了点蛋疼的东西(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;
}
}
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;
}
}
相关文章推荐
- 星期天写了点蛋疼的东西(2)
- 星期天写了点蛋疼的东西(3)
- 蛋疼时候的一些东西
- 作为一个大学才开始入门学计算机编程的孩子想要的东西-----听我扯,你蛋疼,他菊紧,我开心
- 作为一个大学才开始入门学计算机编程的孩子想要的东西-----听我扯,你蛋疼,他菊紧,我开心
- 蛋疼:神马搜索究竟是个神马东西?
- 正则表达式到底是什么东西??
- 电气工程师必备的东西
- Nest,很酷的东西
- 关于位域的一些东西
- 内存调试的东西D/dalvikvm( 809 ): GC_CONCURRENT freed
- 想学IOS开发高阶一点的东西,从何开始
- 【转】使用screen的一些技巧性东西
- 百度地图之清单文件需备注什么东西
- 写个东西还要审核么,昨天的还没写完,今天找不了,隐藏了,别给我自己隐藏啊
- malloc使用细节(东西虽小,出现问题影响挺大,注意留意)
- >>今天逛MS网站,发现如下东西:
- 你关心的东西决定了你的层次
- Object-C 相关东西
- 这几天回家了一趟,奶奶病了,把笔记本带回家,本想用在家的几天把MSN方面的东西整理一下贴出来的!