简体   繁体   English

如何在Java中运行Web动态项目时访问存储在远程位置的欢迎文件?

[英]How to access welcome files on running web dynamic project in java which are stored in remote location?

In web.xml 在web.xml中

<welcome-file>file:C:/Users/abc/Desktop/Design Pages/index.html</welcome-file>
<welcome-file>index.htm</welcome-file>

I want to access file from my local drive not from classpath in eclise project. 我想从本地驱动器而不是eclise项目中的classpath访问文件。

Welcome files, if specified as file, must exist physically within your application. 欢迎文件(如果指定为文件)必须在应用程序中物理存在。 It's not an eclipse thing, it's the nature of the web app your are developing using eclipse (and probably deploying using eclipse). 这不是日食,这是您使用Eclipse开发的Web应用程序的本质(可能使用Eclipse进行部署)。 An option for serving that local file can be to define a servlet + servlet-mapping which then can be used to read the content of that file and set it as the http-response content. 服务该本地文件的一个选项是定义一个servlet + servlet-mapping,然后可以将其用于读取该文件的内容并将其设置为http-response内容。

I don't know your use case, however when it comes to delivery it might be useful to ship the welcome page within your application. 我不知道您的用例,但是,在交付时,将欢迎页面放入应用程序中可能会很有用。

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

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