Re: multi-language url rewiting. Is it possible?

Splash Forums PrettyFaces Users multi-language url rewiting. Is it possible? Re: multi-language url rewiting. Is it possible?


To clarify the outbound rewriting stuff: It will only work if you are using exactly the correct view id (meaning /pages/main/welcome.jsf instead of something like ../../pages/main/welcome.jsf) and if you are using a JSF component to render the link. So it should work if you are using something like this:

<h:link outcome="/pages/main/welcome.jsf">
Click me

You will see that the rendered html contains a link to /en/main/welcome. IMHO you shouldn’t use <h:outputLink> here, because I’m not sure whether it calls the required Servlet API’s that are required for rewriting to work as it is usually used for external links. So you should use <h:link> or <pretty:link> instead.

I tried but in this case a browser with english language would display the welcome page with italian content.

This shouldn’t happen if you are doing it correctly. The general idea is to inject the language code from the URL into a bean that uses it to identify the correct locale and sets it for the view root. Something like this:

<url-mapping id="base">
<pattern value="/#{localeChanger.languageCode}/main" />


public class LocaleChanger {

private String languageCode;

/* getters / setters */

public Locale getLocale() {
return new Locale(languageCode);



<f:view locale="#{localeChanger.locale}">