Struts(Java)
Struts
Apache Struts is a free open-source framework for creating Java web applications.
Web applications differ from conventional websites in that web applications can create a dynamic response. Many websites deliver only static pages. A web application can interact with databases and business logic engines to customize a response.
Web applications based on JavaServer Pages sometimes commingle database code, page design code, and control flow code. In practice, we find that unless these concerns are separated, larger applications become difficult to maintain.
One way to separate concerns in a software application is to use a Model-View-Controller (MVC) architecture. The Model represents the business or database code, the View represents the page design code, and the Controller represents the navigational code. The Struts framework is designed to help developers create web applications that utilize a MVC architecture.
The framework provides three key components:
- A "request" handler provided by the application developer that is mapped to a standard URI.
- A "response" handler that transfers control to another resource which completes the response.
- A tag library that helps developers create interactive form-based applications with server pages.
Homepage: http://struts.apache.org/
Struts请求处理过程简要描述
第一个环节是FilterDispatcher,过滤、包装请求,调用dispatcher的serviceAction方法。主要代码如下: 1UtilTimerStack.push(timerKey); 2 request = prepareDispatcherAndWrapRequest(request, response); 3 &n...
Struts--原理简介(From Inet)
Struts 使用 Model 2 架构。Struts 的ActionServlet 控制导航流。其他Struts 类,比如 Action, 用来访问业务逻辑类。当 ActionServlet 从容器接收到一个请求,它使用URI (或者 路径“path”) 来决定那个Action 将用来处理请求。一个 Action可以校验输入,并且访问业务 层以从数据库或其他数据服务中检索信息。 为校验输入或者使用输入来更新数据...
J2EE学习笔记-Filter中访问Session的问题
Filter Servlet中传递的request和response对象分别是ServletRequest和ServletResponse接口的对象,而不是一般Servlet中的HttpServletRequest和HttpServletResponse接口的对象,ServletRequest是 HttpServletRequest的父接口,很多方法是没有的,比如说request.getSession() ;所以如果想在Filter中读取session对象必须对request做一定的向下转型。 而实现Htt...
J2EE学习笔记--简单的DAO实现
我对DAO的理解就是对数据库的访问封装在一个接口里,当用户需要访问数据库的时候只需要简单的对调用接口,而不需要和数据库有直接的接触。 下面介绍一个简单的DAO对数据库访问的建立: 首先我们需要建立 1、一个DAO接口:UserDAO.java在里面定义数据库操作的所有方法 2、一个实现了DAO接口的类、UserDAOImpl.java,完成了对DAO的实现并且将取得的数据存放...
J2EE学习笔记--制作自己的Taglib
1、实现自定义Taglib的类需要实现javax.servlet.jsp.tagext.IterationTag或者 javax.servlet.jsp.tagext.TagSupport、javax.servlet.jsp.tagext.BodyTag接口,目前J2EE提供了两 个分别实现了这两个接口的类,我们只需要直接继承就可以,它们分别为BodyTagSupport、TagSupport 继承两个类中的一个就可以完成一个属于自己的Taglib类 package cn.dong; impor...
Struts之DispatchAction
今天刚刚看了DispatchAction觉得这个东西有点意思,所以就写点东西,通过它的名字我想应该可以明白它的作用了,用于分发的Action,主要的好处是把一些功能类似的Action放到一个Action中,通过传入的不同参数来觉得执行哪个操作. DispatchAction类是一个抽象类,它实现了父类(Action)的execute()方法,所以它的子类就不用来实现这个方法了,...
用Struts Plugin 加载Hibernate的SessionFactory
系统使用Hibernate作为持久层,我们希望在系统启动时候创建SessionFactory实例,并将SessionFactory存入Application,在应用关闭的时候销毁SessionFactory (1)实现自己的Plugin,并实现init和destory方法 public class SessionFactoryLoaderPlugin implements Plugin...{ private ...
在Struts1.x中使用Interceptor
几个月前,Struts2发布,这个版本较struts1.x版本有了很大变化,其中一个就是增加了拦截器功能。这是个非常有用的功能,可是struts1.x却没有。其实,struts1.x可以配合插件,实现拦截器的功能。 SAIF(Struts Action Invocation Framework)是一个开源组件,它让Struts框架具备Action拦截器与IOC的功能,这样你的1....
一个掌握Struts企业级Web开发框架的实例
俞良松(转载自开放系统世界) Struts是源代码开放的企业级Web应用开发框架,它的设计目的是从整体上减轻构造企业Web应用的负担。本文通过一个Struts应用的实例,帮助你迅速掌握Struts。 Struts是在Jakarta项目下开发的源代码开放软件,由一系列的框架类、辅助类和定制的JSP标记库构成,定位在基于Model 2设计模式的J2EE应用开发。Model 2体系是MVC(Mod...
JSP和Struts解决用户退出问题
在一个有密码保护的Web应用中,正确处理用户退出过程并不仅仅只需调用HttpSession的invalidate()方法。现在大部分浏览器上都有后退和前进按钮,允许用户后退或前进到一个页面。如果在用户在退出一个Web应用后按了后退按钮浏览器把缓存中的页面呈现给用户,这会使用户产生疑惑,他们会开始担心他们的个人数据是否安全。许多Web应用强迫用户退出时关闭整个浏览器...