避免服务器调用不存在的松散资源 [英] Avoid server calls for loose resources that do not exist

查看:31
本文介绍了避免服务器调用不存在的松散资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个在 Java 1.5(与 1.5+ 兼容)上编译的小程序应用程序.它包含一些资源属性文件,这些文件捆绑在同一个 jar 中,与 Java 包平行.

I'm developing an applet application which is compiled on Java 1.5 (compatible with 1.5+). It contains some resource property files that are bundled together in the same jar, which lies parallel to the Java package.

每当我通过小程序访问该资源文件时,它都会向下载小程序的服务器发出请求.之后它从 jar 中读取文件并像以前一样工作,但我不希望它向这些文件发出服务器请求.

Whenever I access that resource file through applet it makes a request to server from where the applet is been downloaded. After that it reads the files from the jar and works as it used to be but I don't want it to make server request for those files.

这是我的java代码访问资源文件的方式.

This is how my java code access the resource file.

ResourceBundle messages = ResourceBundle.getBundle("resources/properties/Messages", locale);

我尝试了两种方式的访问:

I tried access in both ways:

ResourceBundle messages = ResourceBundle.getBundle("resources.properties.Messages", locale);

两者都具有相同的行为.

Both it had the same behaviour.

注意:这些资源在我的网络应用中不能作为松散资源使用.

Note: Those resources are not available as loose resources in my web app.

推荐答案

我从服务器日志中获得了这些详细信息.. 我正在分析我的服务器日志中的 404 和 500 响应..

I got these details from server logs.. I was analyzing my server log for 404 and 500 responses ..

404(未找到)&500(服务器错误)消息可以预期,因为插件正在尝试检查缓存的资源是最新的.为此,它需要检查资源的服务器版本上的上次更新时间.

The 404 (not found) & 500 (server error) messages can be expected because the plug-in is trying to check if the cached resources are up to date. To do that, it needs to check the time last updated on the server version of the resource.

复杂的因素是资源可能位于小程序archive属性中提到的Jar中是与指定的 codebase 相同路径上的松散文件".因此,如果资源位于 Jar 的以下路径中:

The complicating factor is that the resource can be expected to be in a Jar mentioned in the archive attribute of the applet or it can be a 'loose file' on the same path as the codebase specified. So if a resource is in the following path of a Jar:

/resources/properties/Messages_en_US.properties 

JVM 也会检查

${codebase}/resources/properties/Messages_en_US.properties 

以及每个 Jar.

要修复它们,请参阅codebase_lookup 参数.此用例需要:

To fix them, see the codebase_lookup parameter. This use-case needs:

<param name='codebase_lookup' value='false' >

这告诉 JVM,没有资源作为松散文件存储在类路径上,并且只有 Jars 会被搜索.它应该停止经常报告的 404/500 消息(对于理解该参数的新 JRE).

That tells the JVM that there are no resources stored as loose files on the class-path, and only Jars are to be searched. It should stop the 404/500 messages being reported as often (for newer JREs that understand that parameter).

这篇关于避免服务器调用不存在的松散资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆