你用jdom读取的时候,多了一个元素,仔细看你的代码吧
估计是读根目录的下遍历误差
我以前用过jdom现在不太了解了
good luck!

解决方案 »

  1.   

    xsl
    不是很了解
    帮不上忙的
      

  2.   

    刚才得分析好像不对:)你在客户端用的是IE
    jdom在好像在父节点的第一个子节点都是一个空字符串,然后才是你自己的节点,
    我记得好像是这样的,好久没用,忘了:)你看看有没有考虑这种情况?
      

  3.   

    可惜没有用过jdom,愿你的问题早日解决。
      

  4.   

    用<pre></pre>标签把<textarea>标签包起来试试
      

  5.   

    谢谢楼上的朋友!
    问题还是没有解决!其它朋友能否提供一些可能的思路?提供一些线索也可以呀!
    难道这是jdom自身的bug吗?
    多谢!多谢!
      

  6.   

    我的xsl文件是这样写,不知道错在什么地方?<?xml version="1.0" encoding="GB2312"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output indent="yes"/>
    <xsl:template match="/root">
    <html>
    <head>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="form1" method="post" action="/user?actionid=test">
    <table  width="90%" border="0" cellpadding="0" cellspacing="1">
        <tr> 
           <td>
              <textarea name="areaName" style="width:100%;height:200"><xsl:value-of select="name"/></textarea>
           </td> 
        </tr>
    </table>
    <input type="submit" name="submit1" value="保存"></input>&#160;
    <input type="button" name="button1" value="返回" onclick="history.go(-1)"></input>
    </form>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>javaBean中的解析代码如下:Element rootEle=new Element("root");
    con=db.getConnection();
    stmt=con.createStatement();     
        
    Element nameEle=new Element("name");
    sql="select name from table1 where id=1";
    rs=stmt.executeQuery(sql);
    while(rs.next()){
       nameEle.addContent(rs.getString(1));
    }rootEle.addContent(nameEle);
    Document xmlDoc=new Document(rootEle);
    JDOMSource xmlSource=new JDOMSource(xmlDoc);
    TransformerFactory transFactory=TransformerFactory.newInstance();
    StreamSource xslSource=new StreamSource(new FileInputStream(xslFile));
    Transformer transFormer=transFactory.newTransformer(xslSource);
    transFormer.setOutputProperty(OutputKeys.ENCODING,"GB2312");
    StreamResult result=new StreamResult(reponse.getOutputStream());
    transFormer.transform(xmlSource,result); 
    =============================================================
    to javafounder(漂流):
    我是在本机测试,win2k,mssql2k,tomcat4.1.12
    客户端和服务器字符集都用的是GB2312
    ===================================================
    to java831(希望):
    我试了一下<pre></pre>标签,但问题依旧!======================================================
    ======================================================
    ======================================================
    当保存返回时一切正常!可是如果此后进入其它页面然后再次进入此页面时就会多出一个空白行!
    查看生成的HTML文件的代码如下:
    <table cellspacing="1" cellpadding="0" border="0" width="90%">
    <tr>
    <td><textarea style="width:100%;height:200" name="areaName">张三&#13;
    李四</textarea></td>
    </tr>
    </table>