Using Struts2 Tags (I)
16 January 2008Let us create a Start page with links to other actions and resources in the application.
The difference between a traditional and a dynamic web application is that the web applications can create a dynamic response. To refer to dynamic data rom a page, the framework offers a set of tags. Some of the tags are just like HTML tags and provide some added value. Other tags provide controls for data handling and control flow using the java server pages in daynamic web applications.
You can use the Struts Tags to create links to other web resources. Since HTML tags cannot easily access dynamic data provided by the Struts2 framework. Therefore we will be using struts2 tags to do things efficiently. A very common requirement in a web applications is linking to other pages. Now let’s create a Start page with links to other actions. Note the use of Struts2 URL tag.
Start.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <title>Welcome</title> <link href="<s:url value="/css/tutorial.css"/>" rel="stylesheet" type="text/css"/> </head> <body> <h3>Commands</h3> <ul> <li><a href="<s:url action="Register"/>">Register</a></li> <li><a href="<s:url action="Logon"/>">Sign On</a></li> </ul> </body> </html>
Another common use of the link elements is to change locales and regions. On the Hello page, let’s create links to change the user’s locale and to display a message from the application resource/ property files.
Follow the other parts of this post as well.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Using Struts2 Tags (I)