Example of struts2.2.1 anchor tag.
Posted on: January 3, 2011 at 12:00 AM
In this tutorial, you will see the use of anchor tag of struts2.2.1.

Example of struts2.2.1 anchor tag.

In this tutorial, we will introduce you to about the anchor tag of struts2.2.1. It provides a hyperlink from current page to another page. It works as anchor tag of html, but syntax is different .In HTML - <a>, struts - <s:a>.

Directory structure of anchor tag example.

 1- index.jsp  

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"ADS_TO_REPLACE_1

pageEncoding="ISO-8859-1"%>

<html>

<head>ADS_TO_REPLACE_2

<title>Insert title here</title>

</head>

<body>ADS_TO_REPLACE_3

<a href="AnchorTagAction.action">AnchorTagAction</a>

</body>

</html> ADS_TO_REPLACE_4

2-AnchorTagAction.java

package roseindia;

import com.opensymphony.xwork2.ActionSupport;ADS_TO_REPLACE_5

public class AnchorTagAction extends ActionSupport{

private static final long serialVersionUID = 1L;

public String execute() throws Exception {ADS_TO_REPLACE_6

return SUCCESS; } 

}

3-AnchorTag.jsp

<%@ taglib uri="/struts-tags" prefix="s" %>ADS_TO_REPLACE_7

<html>

<head>

<title>Anchor Tag(Data Tag) in struts2.2.1</title>ADS_TO_REPLACE_8

</head>

<body>

<h1>Struts2.2.1 a(Anchor)Tag Example</h1>ADS_TO_REPLACE_9

<ul><li><s:url var="StrutsExample" value="http://www.roseindia.net" />

<s:a href="%{StrutsExample}">Struts Tags Examples........</s:a>

</li><li><s:url value="welcome.jsp" var="welcome" />ADS_TO_REPLACE_10

<s:a href="%{welcome}" >Go to welcome page </s:a>

</ul></body>

</html>

4_struts.xml

<package name="bharat" extends="struts-default" namespace="/" >ADS_TO_REPLACE_11

<action name="AnchorTagAction" class="roseindia.AnchorTagAction">

<result name="success">AnchorTag.jsp</result>

</action>ADS_TO_REPLACE_12

</package> 

5_WelCome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<html><head><title>Insert title here</title>ADS_TO_REPLACE_13

</head><body>

<h1>Welcome Page....</h1>

</body></html>

 

index.jspADS_TO_REPLACE_14

AnchorTag.jsp

ADS_TO_REPLACE_15

StrutsExample.gif

welcome.jspADS_TO_REPLACE_16

Download Select Source Code


Related Tags for Example of struts2.2.1 anchor tag.:

Advertisements

Ads

Ads

 
Advertisement null

Ads