Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Eclipse (Dynamic Web Project) 中的 servlet。我在 Web 内容文件夹中放置了一些图像文件,并带有一个子文件夹 pics。现在有像 pic1.jpg 等图像。
BufferedInputStream bin = new BufferedInputStream(new FileInputStream(new File(location)));
为了检索这些文件,我应该提供什么位置?
试试这个
ServletContext ctx=getServletContext(); InputStream in = ctx.getResourceAsStream("/pics/pic1.jpg");
getResourceAsStream()要求您从"/"代表 Web 应用程序根目录的 a 开始。
getResourceAsStream()
"/"
我知道这可能是一个菜鸟问题,但我真的无法弄清楚。
我被要求修改现有的 php 代码,所以我下载了代码并尝试在我的机器上运行,但我无法让它工作。
据我了解,我们编写 php 代码
<?php //some code ?>
但是我下载的这段代码使用了这样的php代码