Can I call a Struts2 action on click of a html link in html page
I want a Struts2 action to be performed on click of a html link in a html page. My first question is whether is it possible to perform a Struts2 a开发者_开发技巧ction in a html page(not JSP)? If yes, take a look at my code below:
home.html
href="home.action"
struts.xml
action name="home" class="com.struts.action.HomeAction"
result name="Success">loginJSP.jsp
*****web.xml***** I did filter mapping such that everything goes to Struts2
Have you tried this?
<a href="<s:url action="actionName"/>">click here</a>
Or this?
<a href="/abc/actionname.action">Click here</a><br />
Also see: http://struts.apache.org/2.x/docs/url.html
Just curious to know, why can't you use JSP?
<s:url action="actionNameInStrutsXML" method="methodNameInYourClass" var="menuAdmin" />
<s:a href="%{menuAdmin}">Menu</s:a>
In this way you can call the method that you prefer.
Remember to put in your struts config this:
struts.enable.DynamicMethodInvocation" value="true"
精彩评论