Coding your second Jakarta Struts Application

Coding your second Jakarta Struts Application

http://javaboutique.internet.com/tutorials/Struts2/

Introduction

Did the title of the article make you curious? If this is the second application then what was the first one? The answer is, the first application was presented in my previous article about Jakarta Struts, "Stepping through Jakarta Struts". Here I showed you:

  • how to download and install Struts
  • the directory structure of a Struts application
  • how to create the first pieces of a new application
  • the contents and purpose of the configuration files
  • how to build a simple Struts HTML page using taglibs
  • how to code an ActionForm class
  • how to code an Action class
  • and finally how to test your application

The "application" that I used as the example was a simple HTML page containing a form with the common controls--text and textarea fields, radio buttons, a checkbox, a selection list (drop down), and a submit button. The submit button would simply submit the form to the page again, and despite the simplicity of the application, all of the main pieces of the Struts framework were being used.

In this article I'll show you how to take one more step up the Struts ladder. This time we'll build a classic list-detail application with the well-known CRUD-actions: Create, Read, Update, and Delete.

The DVD library application

Reuse is a good thing, so I decided to take the specs for our second application from a previous article of mine, "Java and JDOM: the perfect couple". Here, a small web application that could manage a collection of DVDs was built. The DVD information is held in an XML file. The application consists of two pages, a DVD List page and a DVD Detail page. Here's the List page first:

DVDList.gif

When you click on one of "Id"-hyperlinks you'll go to the Detail page:

DVDDetail.gif

As you can see there are 7 functions in total to implement: list, detail, save, update, create, delete and cancel. The flow of the application is as follows:

StrutsDVDapplication.JPG

In the JDOM article, I used a very simple MVC-architecture using only jsp-pages (even for the controllers) and JavaBeans. The beans can be re-used in the Struts application, and also the html layout. To finish the Struts application we'll have to:

  • write the proper configuration files (struts-config.xml and ApplicationRessources.properties)
  • code ActionForm and Action classes for the 7 functions
  • write the two jsp-pages using Struts tags
[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4082/viewspace-1002354/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/4082/viewspace-1002354/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值