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

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

问题描述

我开发是基于Java 1.5(含1.5+兼容)编译的一个小程序的应用程序。
它包含在同一罐,其中Ja​​va包在于平行捆绑在一起某些资源属性文件。

每当我访问过的applet它使从哪里小程序下载到服务器的请求的资源文件。之后,它读取的jar文件和工作,因为它曾经是,但我不希望它使这些文件服务器的请求。

这是怎么我的Java code访问资源文件。

 资源包的消息= ResourceBundle.getBundle(资源/属性/消息,语言环境);

我试图以两种方式访问​​:

 资源包的消息= ResourceBundle.getBundle(resources.properties.Messages,语言环境);

无论它有相同的行为。

请注意:这些资源是不是在我的web应用程序可以作为松散资源


解决方案

  

我从服务器日志这些细节。我正在分析我的服务器日志中的404和500的响应。


借助 404 (未找到)及 500 (服务器错误)消息可以预期,因为插件是试图检查是否缓存的资源是最新的。要做到这一点,就需要检查最新更新资源的服务器版本的时间。

的复杂因素是,可以将资源预计将在Applet的归档属性 的提到一个Jar 它可以为指定的 codeBase的在同一路径上的松散的文件。所以,如果资源是在一个罐子里的以下路径:

  /resources/properties/Messages_en_US.properties

在JVM也将检查

  $ {codeBase的} /resources/properties/Messages_en_US.properties

以及每个罐子。

要解决这些问题,请参阅<一个href=\"http://docs.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/special_attributes.html#$c$cbase\"相对=nofollow> codebase_lookup 参数。这个用例需要:

&LT; PARAM NAME ='codebase_lookup'值='假'&GT;

这告诉JVM有没有存储在类路径上松散的文件,只罐子资源进行搜索。它应停止 404 / 500 的消息被报道经常(为了解参数较新的JRE)。

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.

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.

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.

解决方案

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

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.

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 

The JVM will also check

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

as well as each Jar.

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

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

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天全站免登陆