如何从applet的要求设置Accept-Language头 [英] How to set Accept-Language header on request from applet

查看:242
本文介绍了如何从applet的要求设置Accept-Language头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉Java,但我需要从我的小应用程序内发出请求到远程web服务。

web服务(.NET 1.1)使用 HttpContext.Current.Request.UserLanguages​​ [0] 来确定要使用的语言。但这个成员的值常是空。

那么,有没有办法通过Accept-Language头以及类似EN-GB设置?

解决方案

如果这是不够好,你知道的小应用程序运行的系统的默认语言(操作系统),可以从<$ C $得到它C>小程序#的getLocale()。如果你真的需要preferred浏览器语言,你可以得到它的服务器端的Servlet容器从的ServletRequest#的getLocale()和动态生成的小程序标签,传递语言code的小程序作为参数。<​​/ P>

I'm not familiar with Java but I need to make a request to a remote webservice from within my applet.

The webservice (.Net 1.1) uses HttpContext.Current.Request.UserLanguages[0] to determine the language to use. But the value of this member is alway null.

So is there a way to pass the Accept-Language header along with something like "en-GB" set?

解决方案

If it is good enough for you to know the default language (operating system) of the system the applet is running, you can get it from Applet#getLocale(). If you really need the preferred browser language, you can get it server-side in a servlet container from ServletRequest#getLocale() and generate the applet tag dynamically, passing the language code to the applet as a parameter.

这篇关于如何从applet的要求设置Accept-Language头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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