我想用xml为html也进行布局,然后再向jsp页面提交,不知道这种想法是否对,在实现上遇到一个问题,恳请大侠们解决下
xml文件
<?xml version="1.0" encoding="GBK"?>
<?xml-stylesheet   type="text/xsl"   href="divx.xsl"?>   
<cc>
<property id="bianhao" name="编号" 
ltop="112" lleft="111" lwidth="55" lheight="59" 
vtop="112" vleft="300" vwidth="55" vheight="59">
<![CDATA[<input type="text" value=""></input>]]> </property>
<property id="xingming" name="姓名" 
ltop="333" lleft="111" lwidth="55" lheight="59" 
vtop="333" vleft="300" vwidth="55" vheight="59">
<![CDATA[<input type="checkbox" value="ss"></input>]]>
</property>
</cc>xsl文件
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:template match="/">
<html><body>
<form action="../test.jsp" method="post"><div>
<xsl:for-each select="//property">
<div>
<div>
<xsl:attribute name="style">background:#F8E0C0;border-color:#F8E0C0;left:<xsl:value-of select="@lleft"/>;top:<xsl:value-of select="@ltop"/>;width:<xsl:value-of select="@lwidth"/>;height:<xsl:value-of select="@lheight"/>;position:absolute</xsl:attribute>
<label><xsl:value-of select="@name"/></label>
</div>
<div>
<xsl:attribute name="style">background:#F8E0C0;border-color:#F8E011;left:<xsl:value-of select="@vleft"/>;top:<xsl:value-of select="@vtop"/>;width:<xsl:value-of select="@vwidth"/>;height:<xsl:value-of select="@vheight"/>;position:absolute</xsl:attribute>
<xsl:value-of select="./text()" disable-output-escaping="yes"/>
</div>
</div>
</xsl:for-each>
<input type="submit" value="提交" />
</div></form>
</body></html>
    </xsl:template>
</xsl:stylesheet>test.jsp页面
    <%
     Enumeration e = (Enumeration)request.getParameterNames();
       while(e.hasMoreElements()){
       String parName=(String)e.nextElement();
       }
       System.out.println("ok!~~~~~~\n+++++++++++++++" + e.toString());
     %>前面用xsl为xml布局可以实现,是参照论坛 hookee 写的,可是,在提交后,test.jsp页面无法获得所有的标签name,e.toString()为java.util.Hashtable$EmptyEnumerator@193f6e2,请问能否实现?怎么解决?

解决方案 »

  1.   

    form中应该有hidden fields用来保存页面提交的值。
    比如:<input type="hidden" name="userid" value="<xsl:value-of select='@id'"/>
      

  2.   

    具体的提交值,我是在<![CDATA[ <input type="text" name="c1" value=""> </input>]]>内填入的,为什么还要有hidden fields呢?我xml文件中的具体html标签加入了name属性,依然不行
    <?xml version="1.0" encoding="GBK"?> 
    <?xml-stylesheet  type="text/xsl"  href="divx.xsl"?>  
    <cc> 
    <property id="bianhao" name="编号" 
    ltop="112" lleft="111" lwidth="55" lheight="59" 
    vtop="112" vleft="300" vwidth="55" vheight="59"> 
    <![CDATA[ <input type="text" name="c1" value=""> </input>]]> 
    </property> 
    <property id="xingming" name="姓名" 
    ltop="333" lleft="111" lwidth="55" lheight="59" 
    vtop="333" vleft="300" vwidth="55" vheight="59"> 
    <![CDATA[ <input type="checkbox" name="c2" value="ss"> </input>]]> 
    </property> 
    </cc> 
      

  3.   

    xls中position:absolute去掉看看<cc> 
    <property id="bianhao" name="编号" 
    ltop="112" lleft="111" lwidth="55" lheight="59" 
    vtop="112" vleft="300" vwidth="55" vheight="59"> 
    <![CDATA[ <input type="text" name="abc" value="xxx"/>]]> </property> 
    <property id="xingming" name="姓名" 
    ltop="333" lleft="111" lwidth="55" lheight="59" 
    vtop="333" vleft="300" vwidth="55" vheight="59"> 
    <![CDATA[ <input type="checkbox"  name="xxx"  value="ss"/>]]> 
    </property> 
    </cc>