Example of anchor(Ajax) in struts2.2.1
Posted on: January 19, 2011 at 12:00 AM
In this section, you will see the use of Ajax anchor tag.

Example of anchor(Ajax) in struts2.2.1

In this example, you will see the use of Ajax(anchor) tag. 

Here, we are changing value of div tag with the help of Ajax anchor tag. 

 1- index.jsp

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




<s:a href="anchorAction.action">Ajax_Anchor_TagExample</s:a>



2_ AjaxAnchorTag.jsp

<%@ page contentType="text/html; charset=UTF-8"%>

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

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


<head><title>Ajax_Anchor_Tag_Example</title><sx:head />



<div id="d1">Bharat</div>

<s:url id="AjaxTag" value="resultAction.action"></s:url>

<sx:a href="%{AjaxTag}" targets="d1">AutoComplete_Tag_Example</sx:a>



3_ AjaxAnchorAction.java

package roseindia.action;

import com.opensymphony.xwork2.ActionSupport;

public class AjaxAnchorAction extends ActionSupport {

public String execute() throws Exception {

return SUCCESS;

public String display() {
return NONE;


4_ struts.xml


<constant name="struts.devMode" value="true" />

<package name="roseindia" extends="struts-default">

<action name="anchorAction" class="roseindia.action.AjaxAnchorAction" method="display">

<result name="none">jspPages/AjaxAnchorTag.jsp</result>


<action name="resultAction" class="roseindia.action.AjaxAnchorAction">

<result name="success">jspPages/DisplayInDivTag.jsp</result>



5_ DisplayInDivTag.jsp






<h2>Changed Value of div </h2>






Download Source Code

Related Tags for Example of anchor(Ajax) in struts2.2.1:



Advertisement null