urlurl-rewritingstruts2struts-1

<html:rewrite page="" > tag equivalent in Struts 2


What is equivalent in Struts2 for <html:rewrite> tag?

<html:rewrite page="/MyAction.action">

Solution

  • You can use url tag to build the url, this is equivalent of html rewrite tag.

    <s:url var="myUrl" action="MyAction"/>
    

    But if you need rewrite the url, then you can use a path

    <s:url var="myUrl" value="/MyAction.action"/>
    

    You can output the value with <s:property value="%{#myUrl}"/> or ${myUrl} in the JSP where possible.

    You can read more about <s:url> tag on the Struts docs site.