I have been struggling for some time on using the struts2-jquery tag.
However, I have not being able to get a working solution of it.
I have attached the JSP , struts configuration and the Action.
Need someone to help me out on this.
JSP:
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-jquery-tags" prefix="sj" %>
<html>
<head>
<sj:head/>
<body>
</head>
<div id="div1">Div 1</div>
<s:url var="ajaxTest" value="/AjaxTest.action"/>
<sj:a id="link1" href="%{ajaxTest}" targets="div1">
Update Content
</sj:a>
</body>
</html>
Struts.xml
<action name="AjaxTest"
class="com.functionality.MenuAction">
<result name="input">/jsps/login.jsp</result>
<result name="success">/jsps/ajax.jsp</result>
</action>
ajax.jsp
abcdefghijklmnopqrstu
MenuAction Action class
import com.opensymphony.xwork2.ActionSupport;
public class MenuAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
public String execute() {
return SUCCESS;
}
}
What other configurations need to be called?
struts2-jquery jar ver used : struts2-jquery-plugin-3.7.0.jar
Solved.
May this be of some help to others,
All I had to do was change the web.xml
as below:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
Earlier I had set the filter as
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<session-config>
So the struts2-jquery tag could not find the corresponding .js files
Solution: change from <url-pattern>*.action</url-pattern>
to <url-pattern>/*</url-pattern>
Thus, please be sure to check the web.xml
for such anomalies which often go overlooked as in my case.