我的标签类如下:package org.tag.image;import java.io.IOException;import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;public class ImageTag extends SimpleTagSupport {

private JspFragment body;
private Image image;

public void setImage(Image image) {
this.image = image;
} public void doTag() throws JspException, IOException {
JspContext jspCtx = getJspContext();
JspWriter out = jspCtx.getOut();
out.println("<img src="+image.getPath()+"/>");
body.invoke(null);
} protected void getJspBody(JspFragment jspBody) {
this.body = jspBody;
}

}tld如下:  <tag>
   <name>logo</name>
   <tag-class>org.tag.image.ImageTag</tag-class>
   <body-content>tagdependent</body-content>
   <attribute>
   <name>image</name>
  
   <required>true</required>
   <rtexprvalue>true</rtexprvalue>
   </attribute>
  </tag>
JSP页面:  <body>
   <jsp:useBean id="image" scope="page" class="org.tag.image.Image"></jsp:useBean>  <%image.setName("123");
image.setPath("./style/image/bg0.jsp");%>
    <div id = "container">
     <div id = "header">
     <div id = "logo">
     <my:logo image="image"></my:logo>
     </div>
     </div>
    </div>
  </body>运行后抛出异常:ServletException raised in SimpleFilter   Unable to convert string "image" to class "org.tag.image.Image" for attribute "image": Property Editor not registered with the PropertyEditorManager
请问这个问题怎么解决,我就是想把一个image对象传入标签,让它在界面上显示。
我的image类:
public class Image { private String name;
private String path;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

解决方案 »

  1.   

    <my:logo image="<%=image%>">
      

  2.   

    还是抛出了异常
    ServletException raised in SimpleFilter   Unable to convert string " <%=image%>" to class "org.tag.image.Image" for attribute "image": Property Editor not registered with the PropertyEditorManager
      

  3.   

    嘿嘿  哥们  我现在也是碰到你这样的问题Property Editor not registered with the PropertyEditorManager能发给邮件给我是怎么解决的么? [email protected]   谢谢了!!