更新时间:2023-09-19 13:06:28
404.html
,因为这是一个应用程序资源,所以它最终可能会嵌入到Jar中. File
对象访问存档 中的资源. URL getURL(String fileName)
为避免混淆,请将其更改为URL getURL(String resourceName)
. Class.getResource(String)
的方式与您之前的问题所讨论的方式相同./
作为前缀来使它们成为绝对",这实际上意味着寻找"该资源来自运行时类路径的根". 404.html
since this is an application resource, it will probably end up embedded in a Jar. File
object. URL getURL(String fileName)
To help avoid confusion, change that to URL getURL(String resourceName)
. Class.getResource(String)
much as discussed on your previous questions./
which effectively means 'look for this resource, from the root of the run-time class-path'. 以便String
可以读取(按照已经建议的方式调整其余代码):
So that String
might read (adjusting the rest of the code as already advised):
private static final String ERROR_404 = "/resources/files/help/404.html";