2016-10-11 73 views
0

我正在使用WebLogic服務器的Spring Framework MVC應用程序。我正在使用jstl 1.2。我有我創建一個自定義標籤庫JSP自定義標記:無法轉換[B @ 33818e的類[B到類[Ljava.lang.Byte

我有這個標記創建:

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' >&nbsp;"); 

       // 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; 
    } 
} 

和這個bean

public class Club implements java.io.Serializable { 


    private byte[] logo; 
    .. 
} 

,並在我的JSP

<tdk:displayImage logo="${club.logo}" /> 

但我得到此錯誤:

javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert [[email protected] of type class [B to class [Ljava.lang.Byte; 
+1

你可以試試Byte []嗎? –

+0

@KorayTugay請轉換爲答案 –

回答

0

最可能的類轉換不適用於原始類型,字節[]應該工作。

相關問題