J2ME中文教程 7 开发无线网络应用程序[8]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

l         Server:包含有关文本以标识响应的服务器。该头只有以下的信息:

Server: Apache/1.3.14(Unix) PHP/4.0.4

 

l         User-Agent:该请求头标的作用是为服务器标识当前用户的,在MIDP2.0规范中并没有要求MIDlet一定要设置User-Agent属性。下面的片段代码演示了设置User-Agent域的版本号为该设备上CLDCMIDP实现的版本号的方法

StringBuffer sb=new StringBuffer(60;

sb.append(“Configuration/”);

sb.append(System.getProperty(“microedition.configuration”));

String prof=System.getProperty(“microedition.profiles”);

int i=0;int j=0;

while ((j=prof.indexof(‘’,i))!=-1){

sb.append(“ Profile/”);

sb.append(prof.substring(i,j));

i=j+i;

}

sb.append(“ Profile/”);

sb.append(prof.substring(i));

c.setRequestProperty(“User-agent”,sb.toString());

 

l         Accept-Language用来设置使用指定的语言请求文档。该请求头的属性一般可以设置为系统属性microedition.locale还是来看一下代码片段:

String locale=System.getProperty(“microedition.locale”);

if(locale!=null){

   c.setRequestProperty(“Accept-Language”,locale);

}

 

本文关键:J2ME中文教程 7 开发无线网络应用程序
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top