在Tomcat内容协商 [英] Content Negotiation on Tomcat

查看:178
本文介绍了在Tomcat内容协商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的Tomcat使用pretty的URL,类似Apache的多视图选项。我试着使用AJP代理的Tomcat与Apache,但.htaccess文件仍然被忽略。
什么是我为Tomcat选项?

I'm trying to get my Tomcat to use pretty URLs, similar to Apache's MultiViews option. I tried using AJP to proxy Tomcat to Apache, but the .htaccess file is still ignored. What are my options for Tomcat?

推荐答案

使用的过滤器。让它侦听 / * 重定向的任何不友好的URL到一个友好的URL和转发的任何友好的URL不友好URL。一个很好的开源的例子是 Tuckey的UrlRewriteFilter 其行为几乎完全一样Apache的的mod_rewrite

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. A good opensource example is Tuckey's UrlRewriteFilter which behaves almost exactly like Apache's mod_rewrite.

如果这涉及到一个全新的web应用是尚待开发,那么更好的办法是采用MVC框架,支持基于REST的URL的,喜欢的 Spring MVC的。或者,也许homegrow前端控制器servlet,这使得使用<一个href=\"http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html#getPathInfo%28%29\"相对=nofollow> 的HttpServletRequest#getPathInfo() 确定PATHINFO。

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. Or maybe homegrow a front controller servlet which makes use of HttpServletRequest#getPathInfo() to determine the pathinfo.

这篇关于在Tomcat内容协商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆