在Apache Tomcat 8.0中的Java应用程序中的IP访问IP的辅助硬盘驱动器
我有一个Java Web应用程序,必须在硬盘驱动器中访问与安装应用程序的文件不同。
我的地址在我的 web.xml 中配置了,该数据可从该数据访问Java代码。
<param-value>//USERNAME:PASSWORD@IP_ADDRESS/HARD_DRIVE_LETTER/FOLDER_NAME/</param-value>
用户名:我想访问
的计算机用户 密码:上述用户的密码
ip_address: Internet协议V4计算机的地址
hard_drive_letter:我想访问 j: 硬盘驱动器
folder_name:我想访问的文件夹的名称
我尝试过没有结果的方法:
<param-value>//USERNAME:[email protected]/J:/Documents/</param-value>
我能够在本地使用此URL,因为我的测试计算机只有一个硬盘驱动器:
<param-value>//USERNAME:[email protected]/Documents/</param-value>
所以我可以访问 c:\ documents 中的文件没有任何问题。
现在,我必须将应用程序导出到另一台计算机,因此我必须在该计算机中安装Apache Tomcat 8.0(版本8.0.30),在硬盘驱动器 i:
中 并且我的应用程序必须访问的数据存储在硬盘驱动器 j:中,
我如何正确输入正确的URL以从应用程序中访问数据?
I have a Java web application that has to access a file in a hard drive different than the one the application is installed in.
I have the address configured in my Web.xml, this data is accessed from the Java code.
<param-value>//USERNAME:PASSWORD@IP_ADDRESS/HARD_DRIVE_LETTER/FOLDER_NAME/</param-value>
USERNAME: User of the computer I want to access to
PASSWORD: Password of the mentioned user
IP_ADDRESS: Internet Protocol v4 Address of the Computer
HARD_DRIVE_LETTER: I want to access to J: hard drive
FOLDER_NAME: Name of the folder I want to access
I have tried this way with no result:
<param-value>//USERNAME:[email protected]/J:/Documents/</param-value>
I have been able to use this URL locally because my test computer had only one Hard Drive:
<param-value>//USERNAME:[email protected]/Documents/</param-value>
So I could access the files in C:\Documents with this method with no problem.
Now, I had to export my application to a different computer, so I had to install Apache Tomcat 8.0 (Version 8.0.30) in that computer, in Hard Drive I:
And the data that my application has to access is stored in Hard Drive J:
How can I properly entry the right URL to access the data from my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法解决了自己的问题。
问题是我没有正确编写我想访问的硬盘驱动器的名称。
要了解资源的真实名称(或共享名称),我必须在这里搜索:
右键单击Windows徽标或启动按钮
选择“管理设备”
系统工具&gt; 共享文件夹&gt; 共享资源
在这里,您可以看到promer “资源名称” 和“文件夹访问路由”
因此,要访问驱动器 j:,我必须
在代码中键入计算机 +“/” +“ j $ ”的IP地址,我使用SMBFile来访问该文件,因此我必须创建一个“ smb:” 的字符串到该参数的开头:
web.xml
从 我能够使用smbfile访问该文件
I managed to solve my own problem.
The issue was that I was not writing properly the name of the hard drive I wanted to access.
To know the real name (or shared name) of a resource, I had to search here:
Right click on Windows logo or Start button
Choose "Manage Equipment"
System Tools > Shared Folders > Shared Resources
Here you can see the promer "Resource Name" with its "Folder Access Route"
So, to access drive J:, I had to type the IP address of the computer + "/" + "J$"
In my code, I used SMBFile to access the file, so I had to create a String adding "smb:" to the beginning of that parameter:
Where I obtained "fileLocationParam" from the Web.xml
This way, I was able to access the file using SMBFile