Friendly URLs

Riot provides two new HandlerMappings: The AdvancedBeanNameHandlerMapping and the PageHandlerMapping. The latter one is part of the riot-pages module and allows you to store your sitemap in the database whereas the AdvancedBeanNameHandlerMapping can be used as drop-in replacement for Spring's  BeanNameUrlHandlerMapping.

Named wildcards

Both HandlerMappings support named wildcards, which are exposed as request attributes:

<bean name="/some/@{myparam}/page.html" class="eg.MyController" />

This is equivalent to "/some/*/page.html" but additionally a request attribute named "myparam" will be exposed by the HandlerMapping that contains the value matched by the wildcard. If someone requests /some/random/page.html the "myparam" attribute will contain the String "random".

You may also specify a type for each wildcard, for example "/foo/bar-@{id:Integer}.html" will convert the wildcard into an Integer value. Currently all primitive wrappers are supported.

Reverse handler look-ups

Both classes implement the ReverseHandlerMapping interface, allowing you to look up the URL for a given handler.

<a href="${common.urlForHandler('postsByCategory', category)}">
  ${category.title}
</a>