Here is a thought...

Set up your action mappings in struts-config.xml without the domain prefix eg
/index.do
/crafts/crafts.do


Then in your filter you can check for the locale prefix and set the locale. In the same filter, construct a new path by removing the locale prefix and forward to the remainder of the path

eg request is /de/index.do --> redirect to /index.do

Struts will then match this and forward to the correct action.
If the request doesn't contain a matching locale then just let the request pass through. eg /crafts/crafts.do would be let through unchanged as the 'crafts. does not match a locale. As the first request should set the locale, you may not need to include it in any subsequent requests so .jsps can link to /index.do instead of /de/index.do


eg
request #1:  /de/index.do  (filter sets locale to de)
request #2: /crafts/crafts.do (uses locale already set to de)

Hmm, you could even change the filter mapping so it is only invoked for the locales that you are covering eg
/de/*
/fr/*


Then you won't have to do let through any unmatched locales eg /crafts/crafts.do would not be checked by the filter, but /fr/crafts/crafts.do is caught, locale set and redirected to /crafts/crafts.do


Ruth, Brice wrote:


The straightforward wildcarding didn't seem to work (it matched against a literal wildcard). Just an FYI for others, I guess .. :)

Adam Hardy wrote:



Hi Brice,
wasn't long before you came back! I was holding out thinking someone else might have a more intuitive solution than mine, but whatever, in your position I write my own taglib based on the html link taglib & add in the locale to the URL in that.


As for the action mappings, I think you're going to have to test it to see if you can use patterns. The struts gurus seem to be keeping their heads down, but maybe one of them will chime in.

Adam

On 10/21/2003 05:40 PM Ruth, Brice wrote:



Greetings.

As per my previous thread on the best way to create a URL structure like:

http://domain/us/whatever
http://domain/de/whatever
etc.

I've implemented the recommendations I received and now have a Filter listening to each request and setting the locale appropriately based on the country code specified in the URL. Working great :) I also have the .jsp I'm working with mapped to an action with a path like /us/index.do.

Now, within this index page, I have links in my navigation, being generated by the Struts HTML tags (html:link) - how would I best go about incorporating the country URL prefix (/us/, /de/, /fr/, etc.) without manually having to insert something like <bean:write name="locale" property="country"/> - also, instead of setting up an action for each .jsp, for each language (/us/index.do; /de/index.do; /us/crafts/crafts.do; /de/crafts/crafts.do; etc.) - what's a better way of doing this? Can I create an action using org.apache.struts.actions.ForwardAction that uses a wildcard? So something like /*/index.do would have a parameter of /index.jsp and /*/crafts/crafts.do would have a parameter of /crafts/crafts.jsp.

I'm looking for guidance - best way of accomplishing my goals of code-reuse, ease-of-maintenance, as well as being able to provide the flexibility in URL naming that marketing would like to see.

Thanks,
Brice










--
Jason Lea




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to