练功场 - 框架结构设计(0分)

Y

yysun

Unregistered / Unconfirmed
GUEST, unregistred user!
经过了概念设计
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1058631
以及,多种现有结构的论证比较(struts, webwork, JSTL ...)
http://www.delphibbs.com/delphibbs/dispq.asp?lid=831468
现在,终于决定提出我的框架结构 (framework) 设计,要点:
1、利用了 JSTL (http://www.delphibbs.com/delphibbs/dispq.asp?lid=995899)
2、可以实现网页级的 MVC (用 JSP Tag,做网页级的调度)
3、也可以做应用系统级的 MVC (象struts那样用一个中央servlet调度)
4、实现了用户输入检验
5、实现了全局转向(global forward)和网页转向(page forward)
6、大部分源程序能自动生成
下面就是一个实现网页级的 MVC 的 JSP 的例子:
<%@page contentType="text/html;charset=gb2312" pageEncoding="gb2312"%>
<%@ taglib prefix="lgc" uri="http://www.richsearch.com/taglibs/lgc" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/ea/xml" %>
<c:catch var="err">
<x:parse var="actionDefs">
<app name="lgc2">
<entity name="project">
<adapter>com.delphibbs.lgc.adapter.ProjectAdapter</adapter>
<action name="list"/>
<action name="display">
<validation>
<input name="projectId" check=""/>
</validation>
<forward name="success" target="dispprj"/>
<forward name="fail" target="listprj"/>
</action>
</entity>
<forward name="authfail" target="login"/>
</app>
</x:parse>
<lgc:useDispatch action="${param.action}" actionDefs="${actionDefs}"/>
</c:catch>
<c:eek:ut value="${err}"/>
 
一些改进:
1、尽量和 struts 兼容(属性名称:pattern 和 path 来自 struts)
2、配置定义 XML 作为 Tag Body 来传入 Tag (不在 JSP 里分析 XML 了,用 Tag 完成)
<%@page contentType="text/html;charset=gb2312" pageEncoding="gb2312"%>
<%@ taglib prefix="lgc" uri="http://www.richsearch.com/taglibs/lgc" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %>
<c:catch var="err">
<lgc:useDispatch action="${param.action}">
<app name="lgc2">
<entity name="project">
<adapter>com.delphibbs.lgc.adapter.ProjectAdapter</adapter>
<action name="list"/>
<action name="display">
<validation>
<input name="projectId" pattern=""/>
</validation>
<forward name="success" path="dispprj"/>
<forward name="fail" path="listprj"/>
</action>
</entity>
<forward name="authfail" path="login"/>
</app>
</lgc:useDispatch>
</c:catch>
<c:eek:ut value="${err}"/>
 
不好意思,看不太懂,这是jsp吗?
 
请问:jstl 仅仅是一个标记库是吗?
 
struts 1.1 包含了 jstl ?
Welcome to Struts! The goal of this project is to provide an open source framework for building web applications.

The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and Extensible Markup Language (XML), as well as various Jakarta Commons packages. Struts encourages application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller (MVC) design paradigm.

Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with any standard data access technology, including Enterprise Java Beans, JDBC, and Object Relational Bridge. [red]For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems. [/red]

The Struts framework provides the invisible underpinnings every professional web application needs to survive. Struts helps you create an extensible development environment for your application, based on published standards and proven design patterns.

Struts is part of the Apache Jakarta Project, sponsored by the Apache Software Foundation. The official Struts home page is at http://jakarta.apache.org/struts.
 
顶部