Download presentation
Presentation is loading. Please wait.
1
Struts1 Apache Struts Dr Jim Briggs
2
Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model 2 It is an Apache project (struts.apache.org) Invented by Craig McClanahan
3
Struts3 What does Struts do? Framework assists in building the Controller component of a webapp Also helps with the View (via some JSP taglibs) Assumes you can handle the Model! –Usually a set of JavaBeans works best
4
Struts4 What does a Struts app consist of? Key classes –ActionServlet (almost never changed) –ActionForm –Action –ActionErrors –ActionForward –ActionMapping struts-config.xml
5
Struts5 ActionForm Represents data on an HTML form Either implement as: –a JavaBean that extends org.apache.struts.action.ActionForm –a DynaActionForm where the properties are defined in struts-config.xml Typically, one ActionForm for each type of HTML form in your application
6
Struts6 Action Deals with a specific HTTP request Extend org.apache.struts.action.Action Implement your code in method: public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionActionForwardActionMapping ActionForm Typically one action for each function of your app
7
Struts7 ActionErrors Object that you use to store the error messages from your app Lots of support in the taglibs for outputting error messages –e.g. tag
8
Struts8 ActionForward Object returned by an Action Identifies what component is to be executed next Usually a JSP page that displays the response Often an Action will return one of 2 or more ActionForwards –One for "success" – JSP that displays results –One for "failure" – JSP that displays error messages
9
Struts9 ActionMapping The "junction box" of a Struts webapp Defines relationship between ActionForms, Actions and ActionForwards Defined in the struts-config.xml file Easier to change the configuration file than change the code
10
Struts10 Struts taglibs Make developing the View (and integrating it with the Controller) easier Three main libraries: –bean –html –logic Need appropriate directives
11
Struts11 Reading Husted chapters 1-3 (tutorial and background) Husted chapters 4-10 (reference) Basham chapter 14 struts-documentation.war
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.