Java Reference
In-Depth Information
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.<html>
5.<head>
6.<title>Hello World</title>
7.</head>
8.<body>
9.Hello
10.<s:property value="name" />
11.</body>
12.</html>
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
 
Search WWH ::




Custom Search