JSP 自定义标签:无法将 [B@33818e 类型 class [B 转换为 class [Ljava.lang.Byte
JSP Custom tags : Cannot convert [B@33818e of type class [B to class [Ljava.lang.Byte
我正在 Spring Framework MVC 应用程序中使用 WebLogic 服务器。我正在使用 jstl 1.2。我有一个我自己创建的自定义标签库
我创建了这个标签:
public class DisplayImageTag extends SimpleTagSupport {
private Collection<Image> images;
private byte[] logo;
private String action;
@Override
public void doTag() throws JspException, IOException {
PageContext pc = (PageContext)getJspContext();
JspWriter out = getJspContext().getOut();
String fullPath = TDKUtils.getTDKPath(pc);
StringBuffer sb = new StringBuffer(" ");
if(action != null) {
action = action.trim();
}
if (this.images!=null) {
for (Image img : this.images) {
Long id = img.getId()!=null ? img.getId() : img.getTempId();
sb.append("<img src='" + fullPath + "/displayImage?" + DisplayImageServlet.IMG_ID + "=" + id+"&resize=true' align='bottom' > ");
// create and show delete button if action arg passed
if (action != null && !action.trim().equals("")) {
sb.append("<a href='" + this.action + "?name=image&id=" + img.getTempId() + "&action=delete'>");
sb.append("<img src='" + fullPath + "/images/delete.png' ");
sb.append("alt='Delete picture' class='whattodo' style='border-width: 0pt;' align='bottom' /></a>");
}
}
}
out.print(sb);
}
public void setImages(Collection<Image> images) {
this.images = images;
}
public void setAction(String action) {
this.action = action;
}
public void setLogo(byte[] logo) {
this.logo = logo;
}
}
还有这个豆子
public class Club implements java.io.Serializable {
private byte[] logo;
..
}
在我的 JSP
<tdk:displayImage logo="${club.logo}" />
但是我得到了这个错误:
javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert [B@33818e of type class [B to class [Ljava.lang.Byte;
很可能 class 转换不适用于原始类型,Byte[] 应该可以。
我正在 Spring Framework MVC 应用程序中使用 WebLogic 服务器。我正在使用 jstl 1.2。我有一个我自己创建的自定义标签库
我创建了这个标签:
public class DisplayImageTag extends SimpleTagSupport {
private Collection<Image> images;
private byte[] logo;
private String action;
@Override
public void doTag() throws JspException, IOException {
PageContext pc = (PageContext)getJspContext();
JspWriter out = getJspContext().getOut();
String fullPath = TDKUtils.getTDKPath(pc);
StringBuffer sb = new StringBuffer(" ");
if(action != null) {
action = action.trim();
}
if (this.images!=null) {
for (Image img : this.images) {
Long id = img.getId()!=null ? img.getId() : img.getTempId();
sb.append("<img src='" + fullPath + "/displayImage?" + DisplayImageServlet.IMG_ID + "=" + id+"&resize=true' align='bottom' > ");
// create and show delete button if action arg passed
if (action != null && !action.trim().equals("")) {
sb.append("<a href='" + this.action + "?name=image&id=" + img.getTempId() + "&action=delete'>");
sb.append("<img src='" + fullPath + "/images/delete.png' ");
sb.append("alt='Delete picture' class='whattodo' style='border-width: 0pt;' align='bottom' /></a>");
}
}
}
out.print(sb);
}
public void setImages(Collection<Image> images) {
this.images = images;
}
public void setAction(String action) {
this.action = action;
}
public void setLogo(byte[] logo) {
this.logo = logo;
}
}
还有这个豆子
public class Club implements java.io.Serializable {
private byte[] logo;
..
}
在我的 JSP
<tdk:displayImage logo="${club.logo}" />
但是我得到了这个错误:
javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert [B@33818e of type class [B to class [Ljava.lang.Byte;
很可能 class 转换不适用于原始类型,Byte[] 应该可以。