How to rewrite URL in Tomcat 6
I'll bui开发者_StackOverflow中文版ld 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.
I've used UrlRewriteFilter as a critical component of a couple of my tomcat-based apps, and have been totally happy with it.
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.
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.
精彩评论