Tomcat 类路径
我的 JSP 中有一个工厂方法,它在预定义位置示例 \abcd\configfolder\conf.xml 中查找配置文件,但我无法控制此路径...我当前该文件位于位置 C:\Myfolder\ project\abcd\configfolder\conf.xml 并且 tomcat 找不到它..所以我想我需要在 tomcat 类路径中包含 C:\Myfolder\project 以便工厂方法找到 conf.xml
谁能告诉我怎么做我能做这个工作吗..
谢谢。卡迪
I have a factory method in my JSP which looks for a config file in a predefined location example \abcd\configfolder\conf.xml and i have no control over this path...i currently have the file at location C:\Myfolder\project\abcd\configfolder\conf.xml and the tomcat does not find it.. so i think i need to include C:\Myfolder\project in my tomcat class path so the factory method finds conf.xml
Can any one tell me how do i make this work..
Thanks. Kaddy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你是对的,Kanddy,将你的文件放在像“conf”这样的文件夹中。将文件夹放在类路径中,然后在代码中通过路径访问文件,如下所示
You are right Kanddy, put you file in a folder like 'conf'. Put the folder in the class path and in you code access the file by the path as
如果您知道绝对路径(例如通过配置属性),那么您可以使用
并且这将起作用。实际上,使用以某种方式传递给 tomcat/您的应用程序的配置属性是定位外部配置文件的正确方法
If you know the absolute path (via a configuration property, for example), then you can use
and this will work. Actually, using a config property passed to tomcat/your app in some way is the proper way to locate the external configuration file
我使用 tomcat 监视器添加了该文件夹。 Tomcat->配置->java->类路径
I added the folder using the tomcat monitor. Tomcat->configuration->java->Classpath