By default, Struts 2 "redirect" is a temporary redirect (302). This makes sense. However, for SEO purposes, I need to issue a permanent redirect (301). Is there an easy way to achieve this?
ServletRedirectResult has a statusCode
that should work. Try setting the statusCode
param on your redirect result. If you're using the Conventions plugin, something like:
@Result(name="success", location="/foo", type="redirect", params={"statusCode", "301"})
or the old style:
<result name="success" type="redirect">
<param name="location">/foo</param>
<param name="statusCode">301</param>
</result>