struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: quick simple question
Date Wed, 29 Jun 2005 04:58:31 GMT
ori wrote:
> currently i map all *.do requests to the action servlet.
> i have an action at myHost/
> i also want myHost/action to map to that same struts action.
> how can i do this?
> thanks a lot.

You only have two options for URL mapping: prefix or extension. In other 
words, you can say 'map any URL beginning ... to this servlet', or 'map any 
URL ending ... to this servlet'. Also, according to the docs, Struts will 
break if you have more than one URL mapping to the same action servlet.

So, possibility one: create two servlet definitions in web.xml, named 
differently, and map one as usual to '*.do' and the other to '*action'. I'm 
not sure that'll work, though, and probably isn't as general as you want.

Possibility two: you can't do this from within standard Struts and will 
have to use something like mod_rewrite.

Possibility three: use prefix mapping instead, so your URL would be 
http://.../do/action and you don't have to worry about '.do' on the end of 
the URL.

Bottom line: there's no way to have a general rule which says 'map .../X 
and .../ to the same thing' for arbitrary X. Maybe if you explain why 
you want to, the list can suggest alternative approaches.

Laurie, Open Source advocate, Java geek and novice blogger:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message