解决不支持cookie的手机访问wap(session)
2006-09-13 17:21
330 查看
在wap解析器中,大量用到了session,为了解决有些手机不支持cookie的问题,使用java的Url重写方法response.encodeURL();
由于我的wml或xhtml页面是动态通过xml+xslt解析生成的。。。所以我在最后解析的方法里加上response.encodeURL
关键代码如下
//replace form @action
List list = objXmlOutput.selectNodes("//*[name()='form']/@action");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
//replace a @href
list = objXmlOutput.selectNodes("//*[name()='a']/@href");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
//replace option @onpick
list = objXmlOutput.selectNodes("//*[name()='option']/@onpick");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
埃。。。用xpath这么久了,才发现 //a/@href 和 //*[name()='a']/@href 是有差别的 ,估计前者是只取第一个节点,后则匹配所有节点,不解 ,……
开始有点讨厌Linux
由于我的wml或xhtml页面是动态通过xml+xslt解析生成的。。。所以我在最后解析的方法里加上response.encodeURL
关键代码如下
//replace form @action
List list = objXmlOutput.selectNodes("//*[name()='form']/@action");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
//replace a @href
list = objXmlOutput.selectNodes("//*[name()='a']/@href");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
//replace option @onpick
list = objXmlOutput.selectNodes("//*[name()='option']/@onpick");
for (Iterator iter = list.iterator(); iter.hasNext();) {
Attribute attribute = (Attribute) iter.next();
attribute.setValue(response.encodeURL(attribute.getValue()));
}
埃。。。用xpath这么久了,才发现 //a/@href 和 //*[name()='a']/@href 是有差别的 ,估计前者是只取第一个节点,后则匹配所有节点,不解 ,……
开始有点讨厌Linux
相关文章推荐
- 用P3P header解决iframe跨域访问cookie/session
- 关于Iframe如何跨域访问Cookie和Session的解决方法
- 用P3P header解决iframe跨域访问cookie/session
- 利用curl来做http访问(支持session,cookie)
- 用P3P header解决iframe跨域访问cookie(转) Iframe session失效
- 关于Iframe如何跨域访问Cookie和Session的解决方法
- 解决访问不同的站点iframe应用session丢失(cookie丢失的问题)的问题
- 让你的空间支持wap访问,虚拟主机支持手机WAP无线访问
- 在IE浏览器中iframe跨域访问cookie/session丢失的解决办法
- 少部分手机浏览器对于COOKIE支持不够导致服务端无法读取session的解决方案
- 用P3P header解决iframe跨域访问cookie/session
- 在IE浏览器中iframe跨域访问cookie/session丢失的解决办法
- 解决同一IP不同端口访问的站点iframe应用session丢失的问题
- 手机浏览器wap网页点击链接触发颜色区块的问题解决办法
- IE下Iframe跨域访问不能写cookie的解决方法
- 解决live555支持real player通过rtp-over-tcp访问问题
- 解决:怕是用了个假的Session哦,每次访问,或刷新就有一个新的SessionID产生
- 用P3P header解决IE下iframe跨域访问时候session丢失的问题
- 解决bootstrap中轮播插件支持手机上的手势滑动的问题
- 今天使用ie6访问有iframe页面时,出现cookie被阻挡的问题解决方法