CHAPTER 4: Building a Web Application Using Struts 2 181
Listing 4-22 illustrates hello.jsp.
Listing 4-22. hello.jsp
1.<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2.pageEncoding="ISO-8859-1"%>
3.<%@ taglib prefix="s" uri="/struts-tags"%>
4.
5.
6.
7.
8.
9.Hello
10.
11.
12.
Line 3: The taglib directive tells the servlet container that this page will be using
the Struts 2 tags.
Line 10: The s:property tag displays the value returned by calling the method
getName of the HelloWorldAction class. The getName method returns a String.
It is this String returned by getName that will be displayed by the s:property tag.
Now you will learn a different technique of declarative configuration provided by Struts 2:
annotations. You can create the new project or modify the project created earlier. Figure 4-13
illustrates the directory structure.
Figure 4-13. HelloWorld project using Struts 2 annotations