模拟Struts2框架Action的实现

1.具体项目结构如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR0AAAEtCAIAAAC6ciOBAAAgAElEQVR4nO2d+18Tx9748+c8fb7fb89pUbCxcmixVvviSMWnN8UjQo1cUvQBhIAIiIJgVVaxR6DWoOGiQEFFU+uNigdBiBesRUqwCGgRIoiIsLnY/f6wYXf2lmzCkmSTz/s1r77YZWZ3UubtzE52PqMgAACQGoW3KwAAfgh4BQDS46ZXd+/dOHL+wNbm5iPnD9y9d4MgiGNVTa+mX6N5RiZerd/bJEEdAUBuuOPV3Xs3tjY3Gw2V+EjH1uZm5YVf79670fvbvdJyHZrtiWkqPF0ndBEA8GPc8erU5V5ieuDh/e/aHhVeeFDx1Xd1X2hOjd3YWV6cuT173/bsffl7S0fHxl3wyogpFUrMSBCEXqVQ6d2ok3vQ9wUAKXHHq63NzQ2/9+h++aFKv+r4D8uTdmq/Sj5FvGy1pzezb6wzL168FPbKiCkVNErMKJlXRkypcOEC4BWwMNi9+uuvv1i/4J6h2Nrc/OH1wa+qL+zcEr49eVtUctP/7jhATFy2J4IgH6sceyXQ+CmvHOQRxogplUpn5dy6MgC4goIgCK1Wm5GRYbVaqbNWqzUjI6OyspK3zN17N6KP3woveRD7vw2fx+o+j919994NYuysPf31Jjxd97PhUWHtfzbtP8d3gYXyyogplZjRWZcHXgELjsJms2VkZISFhVFqkVKRZ2w2G2+xu/duHNhZG/d1RXYKRs4H5u05tTVVtzVV1/Pw6bn2vrDUkys01bd6nzaevcspzWnZ9AlSCr0KHSXazzNP2MvoVfQpUiuC0KuYgzu0LKZijz+piiA3ZZykC8GQERCJgiAIi8VCiTQzM8PSTCRnB9+Q6fzQm3HcPobsGZ3dkvIjJy/j+UqJGTleEUz3UFGo8+RFED3pXGh+vYrtA3Jlxn2RbHqVAjmP1AjMAkRhf76i+qiIiAgxUnV0Db4yXpq4XWke7+/se1H30MxN3994vjlNP/z0Jae00/6KmQftSOh+g30Rlkw8inHvTv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TJaQt55tSpMoFyngqM4bDDs6/pYiypZIaqYa+KBK/kipy8ogJjzJht41P2LquwrH58yjw+ZRmfspys+t5BcY8ExiD9EJrwYP0WvQLvz+CVXJGNV7aZF1RgDJvVPDZppvqrsUnL2KR5bNJ8/KSWv7AHA2PQ9+OxC7wKFGTjFSswhv664a2VSSMTOGnXyIR5ZMJcdvwkf2GPBcYwYhhrKT4ndhpvMDXwys+Qh1fcwBh9/Y+TdpU/eW4m5wOfjONPnuNHjlULXMCjgTEYGec0Quyk1Aav/BZ5eMUbGGPIhA+NzQ6ZZgfH8EHT7OAYXlJ+yts1BQCCkItXvIExHo/OPh6dHRjFB0ZnB0ZnH4/O7v93nbdrCgAEIRevuIExWg/9s+BIY+GRxoIjTYVHGgtLGwtLG4uPNHi7pgBAEHLxCgJjAPJCHl4BgLwArwBAev4/u1Hb5lYxuMYAAAAASUVORK5CYII=" alt="" />

2.配置web.xml

    <filter>
<filter-name>ActionFilter</filter-name>
<!-- 过滤器具体实现类 -->
<filter-class>com.gxxy.action.web.filter.ActionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ActionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

3.actions.xml

<actions>
<action name="list" class="com.gxxy.action.oa.web.ListAction" method="list">
<target name="listing" type="forword" >/WEB-INF/index.jsp</target>
</action>
</actions>

4.Filter具体实现类

--->加载actions.xml配置文件

  

  /**
* 加载配置文件 actions.xml
*
* @return
*/
private Document getDoucment() {
//注意:Document 为org.w3c.dom.Document包中的;
Document doucment = null;
InputStream resourceAsStream = Thread.currentThread().getContextClassLoader()
.getResourceAsStream("actions.xml");
try {
doucment = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(resourceAsStream);
} catch (Exception e) {
e.printStackTrace();
}
return doucment;
}

  -->当过滤器初始化的时候,加载出actions.xml里的内容

  /**
* 初始化
*/
private Map<String, ActionConfig> map = new HashMap<>();
public void init(FilterConfig arg0) throws ServletException {
Document document = getDoucment();
NodeList elementsByTagName = document.getElementsByTagName("action");
//循环取出action标签中的内容
for (int i = 0; i < elementsByTagName.getLength(); i++) {
// 解析action元素
Element action = (Element) elementsByTagName.item(i);
String name = action.getAttribute("name");
String cls = action.getAttribute("class");
String method = action.getAttribute("method");
//将action中加载出的name,class,method 放到ActionConfig对象中
ActionConfig acticonfig = new ActionConfig(name, method, cls);
//将Action对象添加到map中,key为action中的name
map.put(name, acticonfig);
// 解析target元素
NodeList target = document.getElementsByTagName("target");
Map<String, TargetConfig> tarmap = new HashMap<>();
//循环取出target标签中的内容
for (int j = 0; j < target.getLength(); j++) {
Element tar = (Element) target.item(j);
String tarname = tar.getAttribute("name");
String type = tar.getAttribute("type");
String textContent = tar.getTextContent();
//将action中target加载出的name,type及文本内容放到TargetConfig对象中
TargetConfig tarconfig = new TargetConfig(tarname, type, textContent);
//将tarconfig对象添加到tarmap中,key为target中的tarname;
tarmap.put(tarname, tarconfig);
}
acticonfig.setTar(tarmap);
}
}

   -->具体的doFilter的实现

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain arg2)
throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
ActionContext.request = req;
ActionContext.response = resp;
//获取到请求的URI
String url = req.getRequestURI();
//将取到的URI用"/"分隔开
String[] urls = url.split("/");
//得到请求路径里"/"最后的元素
String cmd = urls[urls.length - 1];
/*
* if ("list".equals(cmd)) { ListAction listAction = new ListAction();
* listAction.list(); }
*/
//public boolean containsKey(Object key)如果此映射包含对于指定键的映射关系,则返回 true。
//如果请求的内容在map中
if(map.containsKey(cmd)){
ActionConfig actionConfig = map.get(cmd);
try {
//通过反射根据类的全限定名称找到这个类
Class class1 = Class.forName(actionConfig.getCls());
//实例化这个类
Object interfaces = class1.newInstance();
//根据配置里的方法名通过反射找到类中的那个方法
Method method = class1.getMethod(actionConfig.getMethod());
//String invoke为具体实现方法里面的返回值
String invoke = (String) method.invoke(interfaces);
//调用Action中的Target map属性
Map<String, TargetConfig> tarmap = actionConfig.getTar();
//如果方法的返回值在target标签中有
if(tarmap.containsKey(invoke)){
TargetConfig targetConfig = tarmap.get(invoke);
//取出type
String type = targetConfig.getType();
//取出标签的文本内容
String target = targetConfig.getTarget();
//如果type是"forward",那么请求转发,否则重定向
if("forword".equals(type)){
req.getRequestDispatcher(target).forward(req, resp);
}else{
resp.sendRedirect(target);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

5.config包为Action对象和target对象包

  --->ActinConfig对象的字段:

   

public class ActionConfig {
  
  //action中的name
private String name;
  //action中的方法
private String method;
  //action中的class
private String cls;
  //action中的target标签
private Map<String,TargetConfig> tar;

  --->TargetConfig对象的字段

public class TargetConfig {
//target标签中的name
private String name;
//target标签中的type
private String type;
//target标签中的文本内容
private String target;

6.context包中ActionContext的具体实现

public class ActionContext {
public static HttpServletRequest request;
public static HttpServletResponse response; }
上一篇:SRE_ Google运维解密


下一篇:Android学习之——ListView下拉刷新