我在 Tomcat 7.0.22(Java 1.6、MacOS Lion)中部署了 .war 存档。这场战争被称为“myapp.war”,因此 Tomcat 正在服务 http://localhost/myapp (已将战争扩大到/webapps/myapp)。这是通常的行为
,当访问对应于目录的 url 时,应该附加“/”。为了使静态文件(.css、.js ..)正常工作,这是必需的,但是对于 Tomcat 附带的示例站点来说,这是可行的(例如访问 http://127.0.0.1:8080/examples
突然重新映射到 http://127.0.0.1:8080/examples/
),在我的网站上,tomcat 没有添加任何“/”来搜索静态文件 破碎的。当手动调用 localhost:8080/myapp/ 时(<-- 我添加斜杠),一切正常。
应该发生什么事?请注意,我没有触及任何 Tomcat 设置,我只是尝试直接从 Apache 的 zip 文件中获得的内容!
谢谢
I deployed a .war archive in Tomcat 7.0.22 (Java 1.6, MacOS Lion). The war is called "myapp.war" and so Tomcat is serving http://localhost/myapp (having expanded the war in /webapps/myapp). This is the usual behavious
When accessing a url that corresponds to a directory, it should append "/" . For having static files (.css, .js..) working correctly, this is needed, but while with the sample sites that ship with Tomcat this works (for example visiting http://127.0.0.1:8080/examples
suddenly remaps to http://127.0.0.1:8080/examples/
), on my site tomcat doesn't add any "/" making the search for static files broken. When manually calling localhost:8080/myapp/
(<-- I add the slash) everything works fine.
What should be going on? Mind that I haven't touched any Tomcat setting, I'm just experimenting with what comes out directly from Apache's zip file!
Thanks
发布评论
评论(1)
首先你应该更多地解释你的情况。正如 @mico 在这里所说的是一个解决方案:
解决方案的想法基于:
您可以在此处阅读更多内容: http://jersey.576304.n2.nabble.com/Tomcat-trailing-slashes-and-welcome-files-td4684494.html
这里表示:
如果您有“/*”映射,那么 Tomcat 不会重定向
再一个:您应该看到 tomcat 如何记录您的请求并确定主要问题。
Firstly you should explain more about your situation. As @mico has told here is a solution:
The idea on solution based on:
Here you can read more: http://jersey.576304.n2.nabble.com/Tomcat-trailing-slashes-and-welcome-files-td4684494.html
Here says that:
If you have a '/*' mapping, then Tomcat won't redirect
One more: you should see how tomcat logs your request and decide the main problem.