简体   繁体   English

Tomcat上的内容协商

[英]Content Negotiation on Tomcat

I'm trying to get my Tomcat to use pretty URLs, similar to Apache's MultiViews option. 我试图让Tomcat使用漂亮的URL,类似于Apache的MultiViews选项。 I tried using AJP to proxy Tomcat to Apache, but the .htaccess file is still ignored. 我尝试使用AJP将Tomcat代理到Apache,但是.htaccess文件仍然被忽略。 What are my options for Tomcat? 我对Tomcat有哪些选择?

Use a Filter. 使用过滤器。 Let it listen on /* and redirect any unfriendly URL to an friendly URL and forward any friendly URL to an unfriendly URL. 让它侦听/* 并将任何不友好的URL 重定向到友好的URL,并将任何友好的URL 转发到不友好的URL。 A good opensource example is Tuckey's UrlRewriteFilter which behaves almost exactly like Apache's mod_rewrite . Tuckey的UrlRewriteFilter是一个很好的开源示例,其行为几乎与Apache的mod_rewrite完全一样。

If this concerns a brand new webapplication which is yet to be developed, then a better way is to adopt a MVC framework which supports RESTFul URL's, like Spring MVC . 如果这涉及尚未开发的全新Web应用程序,那么更好的方法是采用支持RESTFul URL的MVC框架,例如Spring MVC Or maybe homegrow a front controller servlet which makes use of HttpServletRequest#getPathInfo() to determine the pathinfo. 或者,可能是在前端控制器servlet本地增长,该servlet使用HttpServletRequest#getPathInfo()确定pathinfo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM