当前位置:首页 > 技术问答集
firefox

taglib嵌套报错,求救!

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

全部代码如下,内容比较多:  
  package   jsp;  
   
  import   java.io.ioexception;  
  import   javax.servlet.jsp.jspexception;  
  import   javax.servlet.jsp.tagext.bodytagsupport;  
  import   org.apache.taglibs.standard.lang.support.expressionevaluatormanager;  
   
  public   class   tag3   extends   bodytagsupport  
  {  
    private   object   value   =   null;  
    private   object   output   =   null;  
   
    public   void   setoutput(object   output)  
    {  
      this.output   =   output;  
    }  
    public   object   getvalue()  
    {  
      return   value;  
    }  
    public   void   setvalue(object   value)throws   jspexception  
    {  
      this.value   =   expressionevaluatormanager.evaluate(  
                          "value",   value.tostring(),   object.class,   this,   pagecontext);  
    }  
    public   int   dostarttag()  
    {  
      return   eval_body_include;  
    }  
    public   int   doendtag()throws   jspexception  
    {  
      try  
      {        
        pagecontext.getout().print(output);  
      }  
      catch   (ioexception   e)  
      {  
        throw   new   jspexception(e);  
      }  
      return   eval_page;  
    }  
  }  
  --------------------------------------------  
  package   jsp;  
   
  import   javax.servlet.jsp.jspexception;  
  import   javax.servlet.jsp.tagext.bodytagsupport;  
  import   org.apache.commons.beanutils.propertyutils;  
   
  public   class   tag4   extends   bodytagsupport  
  {  
    private   string   property   =   null;  
   
    public   void   setproperty(string   property)  
    {  
      this.property   =   property;  
    }  
   
    public   int   doendtag()throws   jspexception  
    {      
    tag3   parent   =(tag3)getparent();      
      if(parent==null)    
        throw   new   jspexception("can   not   find   parent   tag   ");  
      try  
      {    
        object   propertyvalue   =   propertyutils.getproperty(parent.getvalue(),   property);  
        parent.setoutput(propertyvalue);  
      }  
      catch   (exception   e)  
      {  
        throw   new   jspexception(e);  
      }  
      return   eval_page;  
    }  
  }  
  -----------------------------------------  
  package   jsp.vo;  
   
  public   class   man  
  {  
    private   string   name   =   null;  
    private   int   age   =   0;  
    public   static   string   tou(string   s)   {  
            return   s;  
        }  
   
    public   int   getage()  
    {  
      return   age;  
    }  
    public   void   setage(int   age)  
    {  
      this.age   =   age;  
    }  
    public   string   getname()  
    {  
      return   name;  
    }  
    public   void   setname(string   name)  
    {  
      this.name   =   name;  
    }  
  }  
  ------------------------------------------  
  <?xml   version="1.0"   encoding="iso-8859-1"   ?>  
  <!doctype   taglib  
      public   "-//sun   microsystems,   inc.//dtd   jsp   tag   library   1.2//en"  
      "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">  
  <taglib>  
    <tlib-version>1.0</tlib-version>  
    <jsp-version>1.2</jsp-version>  
    <short-name>gq</short-name>      
   
  <tag>  
      <name>with</name>  
      <tag-class>jsp.tag3</tag-class>  
      <body-content>jsp</body-content>  
      <attribute>  
        <name>value</name>  
        <required>false</required>  
        <rtexprvalue>true</rtexprvalue>  
      </attribute>  
    </tag>  
   
    <tag>  
      <name>nestedout</name>  
      <tag-class>jsp.tag4</tag-class>  
      <body-content>empty</body-content>  
      <attribute>  
        <name>property</name>  
        <required>false</required>  
        <rtexprvalue>false</rtexprvalue>  
      </attribute>  
    </tag>  
  </taglib>  
  ----------------------------------------  
  <%@   page   contenttype="text/html;charset=gbk"%>  
  <%@   page   import="jsp.vo.man"%>  
  <%@   taglib   uri="/web-inf/tlds/gq.tld"   prefix="gq"%>  
  <%  
  man   man   =   new   man();  
  man.setname("gq");  
  request.setattribute("man",man);  
  %>  
  <gq:with   value="${man}">  
    <gq:nestedout   property="name"/>  
  </gq:with>  
  ---------------------------------------  
  运行jsp报错信息:  
  javax.servlet.servletexception:   javax.servlet.jsp.jspexception:   unknown   property   name  
  org.apache.jasper.runtime.pagecontextimpl.dohandlepageexception(pagecontextimpl.java:821)  
  org.apache.jasper.runtime.pagecontextimpl.handlepageexception(pagecontextimpl.java:758)  
  org.apache.jsp.jsp.jstl_jsp._jspservice(jstl_jsp.java:80)  
  org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:94)  
  javax.servlet.http.httpservlet.service(httpservlet.java:810)  
  org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:324)  
  org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:292)  
  org.apache.jasper.servlet.jspservlet.service(jspservlet.java:236)  
  javax.servlet.http.httpservlet.service(httpservlet.java:810)  
  org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:75)  
   
   
  root   cause    
   
  java.lang.nosuchmethodexception:   unknown   property   name  
  org.apache.commons.beanutils.propertyutils.getsimpleproperty(propertyutils.java:1175)  
  org.apache.commons.beanutils.propertyutils.getnestedproperty(propertyutils.java:772)  
  org.apache.commons.beanutils.propertyutils.getproperty(propertyutils.java:801)  
  jsp.tag4.doendtag(tag4.java:27)  
  org.apache.jsp.jsp.jstl_jsp._jspx_meth_gq_nestedout_0(jstl_jsp.java:134)  
  org.apache.jsp.jsp.jstl_jsp._jspx_meth_gq_with_0(jstl_jsp.java:107)  
  org.apache.jsp.jsp.jstl_jsp._jspservice(jstl_jsp.java:71)  
  org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:94)  
  javax.servlet.http.httpservlet.service(httpservlet.java:810)  
  org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:324)  
  org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:292)  
  org.apache.jasper.servlet.jspservlet.service(jspservlet.java:236)  
  javax.servlet.http.httpservlet.service(httpservlet.java:810)  
  org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:75)  
   
   
   
 

.

· 网友精彩回答:

© 2006-2008 All Rights Reserved