views:

443

answers:

3

Hello.

I'll build a web application and I want to use url rewriting. In apache this is done with mod_rewrite. But how can I rewrite urls with Tomcat 6?

I want to use Struts 2 framework.

A: 

I've used UrlRewriteFilter as a critical component of a couple of my tomcat-based apps, and have been totally happy with it.

Jonathan Feinberg
Have you used it with Struts?
Enrique
No; I've never used Struts at all, sorry!
Jonathan Feinberg
But the author of UrlRewriteFilter does mention Struts in particular on the front page, in a context that suggests that it's compatible.
Jonathan Feinberg
A: 

You can do wildcard mappings in your struts.xml:

<action name="*Crud" class="example.Crud" method="{1}">
...

Then I think you can set your default action extension to / in struts.properties:

struts.action.extension=/

As for the URL filter, here's a good blog post.

Droo
A: 

It could be a good idea to have Apache as a web server for static content in front of Tomcat application server.

You can then use Apache's mod_rewrite and Tomcat.

In any case, there's a similar question.

antispam