Learn Java for Web Development

(Tina Meador) #1
CHAPTER 4: Building a Web Application Using Struts 2 183

Listing 4-25. actionPackages Init Parameter



actionPackages
com.apress.helloworld.action

The Convention plug-in uses the Action class name to map the action URL. The Convention plug-in
first removes the word Action at the end of the class name and then converts the camel-case name
to dashes. So, by default HelloWorldAction will be invoked for the request URL hello-world. But
if you want the action to be invoked for a different URL, then you can do this by using the action
annotation.


Tip You can find the list of all Struts 2 annotations at http://struts.apache.org/release/2.3.x/
docs/annotations.html.

In the section that follows, you will develop the bookstore web application using Struts 2.


Bookstore Web Application


In this section, you will progressively develop the bookstore application including the following
functionality:


   The login functionality
 Templates
 Integration with the data access layer
 Login via a database
 Selection of categories from a database
 Listing books by category

The complete code for the application is available in the downloadable archive on the Apress website.


The Login Functionality

Figure 4-14 shows the initial login screen.

Free download pdf