首页 > 代码库 > 自己写的struts1框架

自己写的struts1框架

前言
正文


自定义Struts1


commons-digester.jar解析XML
实现XML标签到对象的转换

1.根据目标XML的结构定义解析规则文件


参照rule.xml

2.创建集合对象接收封装解析的XML


ModelConfig config = new ModelConfig();
Digester digester = DigesterLoader.
createDigester(ActionServlet.class.getClassLoader().getResource("com/zhongx/struts/rule.xml"));
//将存储集合对象传入
digester.push(config);
//解析目标 XML
digester.parse(ActionServlet.class.
getClassLoader().getResourceAsStream("mystruts.xml"));


文件清单

src目录的struts有


1.ActionServlet.java
<script src="https://code.csdn.net/snippets/418121.js" type="text/javascript"></script>
2.ModelConfig.java
<script src="https://code.csdn.net/snippets/418125.js" type="text/javascript"></script>
3.GolableResultConfig .java
<script src="https://code.csdn.net/snippets/418129.js" type="text/javascript"></script>
4.rule.xml规则文件
<script src="https://code.csdn.net/snippets/418135.js" type="text/javascript"></script>
5.ActionConfig 
<script src="https://code.csdn.net/snippets/418138.js" type="text/javascript"></script>
6.ForwardConfig 
<script src="https://code.csdn.net/snippets/418140.js" type="text/javascript"></script>
7.ActionForm.java
<script src="https://code.csdn.net/snippets/418143.js" type="text/javascript"></script>
8.Action.java
<script src="https://code.csdn.net/snippets/418146.js" type="text/javascript"></script>
9.,FormBeanConfig .java 
<script src="https://code.csdn.net/snippets/418148.js" type="text/javascript"></script>




form目录下的


LoginForm.java
<script src="https://code.csdn.net/snippets/418152.js" type="text/javascript"></script>

action目录下的示例代码


LoginAction.java
<script src="https://code.csdn.net/snippets/418155.js" type="text/javascript"></script>

src目录下的配置文件


mystruts.xml
<script src="https://code.csdn.net/snippets/418156.js" type="text/javascript"></script>

WebRoot目录下的jsp文件

1.index.jsp
<script src="https://code.csdn.net/snippets/418163.js" type="text/javascript"></script>


2.fail.jsp
<script src="https://code.csdn.net/snippets/418167.js" type="text/javascript"></script>


3.success.jsp
<script src="https://code.csdn.net/snippets/418170.js" type="text/javascript"></script>

WEB-INF目录下的jar包和配置文件web.xml


1.web.xml
<script src="https://code.csdn.net/snippets/418172.js" type="text/javascript"></script>

2.lib目录下的jar包

commons-logging.jar
commons-lang.jar
commons-digester.jar
commons-collections.jar
commons-beanutils.jar












总结