解决不支持cookie的手机访问wap(session)

在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


posted on 2006-09-13 17:21 夜隼 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/yesun/archive/2006/09/13/503402.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值