2

I've created a friendly URL file for my abc-portlet (the portlet uses the DefaultFriendlyURLMapper):

<routes>
    <route>
        <pattern>/{urlTitle}</pattern>
        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
        <implicit-parameter name="struts_action">/view</implicit-parameter>
    </route>
</routes>

This works like a charm, but I would like to understand, if there's a way to omit the "-" in the friendly URL? I.e.

http://.../page/-/abc/title

should be

http://.../page/abc/title
Thorsten Laux
  • 100
  • 12

1 Answers1

2

I found the solution.

You have to extend the DefaultFriendlyURLMapper and override the isCheckMappingWithPrefix method. (..and of course define this class as your FriendlyURLMapper.)

public class FriendlyUrlWithoutMinus extends DefaultFriendlyURLMapper {

    @Override
    public boolean isCheckMappingWithPrefix() {
        return false;
    }

}
Thorsten Laux
  • 100
  • 12
  • I was able to get the url to work without `-`. However when the render URL routes to the friendly URL, it includes the `-` in the URL. Were you also able to manipulate or change the URL pattern which replaces the parameterized url and remove `-` in it as well. We dont want to remove the `-` manually in the URL – ughai Feb 02 '16 at 12:56
  • @ughai I'm sorry, but the above only impacts the resulting/friendly URL and I did not have the requirement to change the source URL format. – Thorsten Laux Feb 02 '16 at 13:30