Tomcat 看不到新文件 [英] Tomcat not seeing new files

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

问题描述

我正在创建一个应用程序,它在我的 WebContent 文件夹中生成一些文件/目录,我希望 Tomcat 提供这些静态文件(一些后台作业的日志).

I am creating an application which produces some files/directories in my WebContent folder and I would like Tomcat to serve these static files (logs of some background jobs).

但是 Tomcat 似乎无法识别新文件(可能是新文件夹中的文件),并且不断为它们返回 404.Tomcat重启后,文件就OK了.

However Tomcat does not seem to recognize new files (maybe files in new folders), and it keeps returning 404 for them. After Tomcat restart, the files are served Ok.

我使用的是 Tomcat 7.0,在 Eclipse 中形成.文件由默认 servlet 提供.

I am using Tomcat 7.0, form within the Eclipse. The files are served by the default servlet.

我假设 Tomcat 最初以某种方式遍历 WebContent,它只是使用这个缓存的文件列表来实现更快的操作.有没有办法禁用这种行为(或者:提供其他进程生成的新文件的正确方法是什么)?

I assume that Tomcat somehow traverses WebContent initially and it just uses this cached list of files for faster operation. Is there a way to disable such a behavior (or maybe: what is the right way to serve new files generated by other processes)?

感谢您的帮助/建议.我是 Tomcat 的新手,所以我可能会忽略一些基本的东西.

Thanks for help/suggestions. I am quite newbie to Tomcat, so I might be overlooking something basic.

更新(基于公认的解决方案)

webapp 文件夹中似乎有一些二元性.一个在 Eclipse 项目中(由 getServletContext().getRealPath 返回,另一个默认位于 Eclipse 元数据中的某处,可以在 wtp.deploy 属性.文件以某种方式从 Eclipse 复制到部署目录.当我开始在 wtp.deploy 下生成文件时,问题得到解决.

There seems to be some duality in the webapp folder. One is in the Eclipse project (and is returned by getServletContext().getRealPath, the other is by default somewhere in Eclipse metadata and can be seen in launch config in wtp.deploy property. The files are somehow copied from Eclipse to the deploy dir. When I started to generate my files under wtp.deploy, the problem got fixed.

然而,我仍然不知道如何以适当的方式解决这个问题,这在 Eclipse WTP 和正常的 Tomcat 条件下都可以工作.

However, I still don't know, how to solve this in proper way, which will work both under Eclipse WTP and in normal Tomcat conditions.

更新

最终的解决方案是完全避免 DefaultServlet.我使用了基于 http:/的 FileServlet/balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html 并且它工作正常.

The final solution was to avoid DefaultServlet at all. I used FileServlet based on http://balusc.blogspot.com/2009/02/fileservlet-supporting-resume-and.html and it works fine.

推荐答案

我对 Netbeans 有类似的经验——它通常将编译后的文件放入新文件夹并在该文件夹中工作.不确定你是否是这种情况;但如果放置在正确的文件夹中,文件应该可用.

I had similar experince with Netbeans- it usually places compiled files into new folder and works with that folder. Not sure if that's the case with you; but files should be available if placed in the right folder.

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

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