现在对方服务器返回的内容中含有<br/>,在我的页面中直接显示为<br/>。action中我这样处理Result3.replaceAll("<br/>", "");但是没起作用,这是什么原因啊?

解决方案 »

  1.   

    其实页面显示的是&lt;br/&gt;Result3.replaceAll("&lt;br/&gt;", "");
      

  2.   

    先把这些数据在后台输出下 判断下究竟是什么&lt; &gt; 你获得的时候那个< 或者 > 是这两个 所以你替换的时候得给他换成 Result3.replaceAll("&lt;br&gt;", "");如果还不好使的话 另外你replace <br/>的时候前面带了个空格 把他去掉
      

  3.   

    Result3.replaceAll("<br/>", "\r\n");
    试试
      

  4.   

    Result3里面有<br/>吗?
    如果有的话,可能是你前面加了空格的原因,大小写也要注意 
      

  5.   

    返回的内容呢是这个样子的。
    手机号:1590058****<br/>
     归属地:上海<br/>
    卡类型:移动全球通卡<br/>
    Result3.replaceAll("&lt;br/&gt;", "");这种方法是行不通的啊
      

  6.   

    Result3.replaceAll("&lt;br/&gt;", "");
    把关于这个地方的的代码贴下
      

  7.   

    public String process() {
    client.getHostConfiguration().setHost( "wap.l.cn" , 80, "http" );
    HttpMethod method;
    try {
    method = Mobile.getGetMethod(tel);
    try {
    client.executeMethod(method);
    String Result2=new String(method.getResponseBodyAsString());
    String[] Result3 = Result2.split("\n");
    Result = new String[Result3.length];
    int i = "<br/>".length();
    for(int j=0;j<Result3.length;j++){
    for(int t=0;t<Result3[j].length()-i;t++)
    { if(Result3[j].regionMatches(0,"<br/>",0,i)==true) 
    Result3[j].replaceAll("<br/>", "");}
    Result[j] = Result3[j];
    }
          method.releaseConnection();
    } catch (HttpException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();

    } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
    }  


    return SUCCESS;
    }
      

  8.   

    replaceAll这个方法,我只成功替换过“,”,其他的字符和字符串都没替换成功。
      

  9.   

    如果可以用el表达式的话,可以试下el表达式,我不记得el表达式会不会过滤了。另外如果是用struts的话,bean:write 标签有个filter属性,可以设置是否过滤。jstl估计也有类似的标签的。
      

  10.   

    Result3[j].replaceAll("&lt;br/&gt;", "");这个我替换了,其它也得替换吗?
      

  11.   

    还是用replace方法,先对“<”、“>”和“/”进行转义,
    “\<”代替“<”
    “\>”代替“>”
    “\/”代替“/”
    试试看
      

  12.   

    谁会解析啊,比如说我只想获取其中的手机号和归属地。
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
    <wml>
    <card title="乐活-[北京]">
      <p>
          <a href="/tel/tel_index.php?city_id=010&amp;sid=&amp;tuid=22128034">归属地</a>-&gt;查询结果
      <br/>
    手机号码归属地查询<br/>
       <input name="tel" maxlength="50" value="" size="19"/><br/>
    &gt;<anchor>查询
    <go method="get" href="/tel/tel_search.php">
    <postfield name="city_id" value="010"></postfield>
    <postfield name="tuid" value="22128034"></postfield>
    <postfield name="sid" value=""></postfield>
    <postfield name="tel" value="$tel"></postfield>
    </go>
    </anchor>
        <br/>
       
        手机号:1590058****<br/>
        归属地:上海<br/>
        卡类型:移动全球通卡<br/>
       
            <a href="wtai://wp/mc;1590058****">直接拨打</a><br/>
        <a href="wtai://wp/mc;179511590058****">加17951拨打</a><br/>
                  <a href="/opinion/list.php?city_id=010&amp;tuid=22128034">查询结果不满意?</a><br/>
          <br/>
        <anchor>返回上页<prev/></anchor><br/>
    <a href="/search/category.php?city_id=010&amp;tuid=22128034&amp;cate_name=%E7%BE%8E%E9%A3%9F&amp;sid=">美食</a>
    <a href="/search/category.php?city_id=010&amp;tuid=22128034&amp;cate_name=%E5%A8%B1%E4%B9%90&amp;sid=">娱乐</a>
    <a href="/search/category.php?city_id=010&amp;tuid=22128034&amp;cate_name=%E6%9C%8D%E5%8A%A1&amp;sid=">服务</a>
    <br/>
    <a href="/index.php?city_id=010&amp;tuid=22128034&amp;sid=">乐活首页</a><br/>
    乐活<br/>
    09-22 14:52 </p>
    </card></wml>