Home Struts Struts Struts2.2.1 Tags Example of struts2.2.1 anchor tag.

Ask Questions?

View Latest Questions


 
 

Example of struts2.2.1 anchor tag.
Posted on: January 3, 2011 at 12:00 AM
Advertisement
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"

pageEncoding="ISO-8859-1"%>

<html>

<head>

<title>Insert title here</title>

</head>

<body>

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

</body>

</html> 

2-AnchorTagAction.java

package roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class AnchorTagAction extends ActionSupport{

private static final long serialVersionUID = 1L;

public String execute() throws Exception {

return SUCCESS; } 

}

3-AnchorTag.jsp

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

<html>

<head>

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

</head>

<body>

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

<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" />

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

</ul></body>

</html>

4_struts.xml

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

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

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

</action>

</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>

</head><body>

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

</body></html>

 

index.jsp

AnchorTag.jsp

StrutsExample.gif

welcome.jsp

Download Select Source Code


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


DMCA.com