我想知道为什么我对此一无所知。我有一个从 SQL Server 2008 返回字节数组的函数,但我什么也没得到,为什么?.getWhiteLabelingLogo() 是一个函数,它返回一个带有我想在 jsp 页面上显示的图像的 byte[]。我访问这个
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.rmi.RemoteException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.apache.axis.MessageContext;
import org.apache.struts2.ServletActionContext;
import org.datacontract.schemas._2004._07.CCIS_Web_Services_PublicApi.PapiAccountInfo;
import org.datacontract.schemas._2004._07.CCIS_Web_Services_PublicApi.PapiUserInfo;
import Services.Web.CCIS.BasicHttpBinding_PublicApiServiceStub;
import Services.Web.CCIS.PublicApiService_PortType;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ShowImageAction extends ActionSupport{
Map session;
private byte[] itemImage;
private InputStream str = null;
public String execute() throws RemoteException {
System.out.println("Estoy aquí");
HttpServletResponse response = ServletActionContext.getResponse();
session = ActionContext.getContext().getSession();
PublicApiService_PortType puerto=(PublicApiService_PortType) session.get("puerto");
((BasicHttpBinding_PublicApiServiceStub)puerto).setMaintainSession(true);
MessageContext ctx=(MessageContext) session.get("contexto");
PapiUserInfo[] users;
users = puerto.getUsers();
Long accountID=users[0].getID();
PapiAccountInfo info=puerto.getAccountInfo(accountID);
itemImage=info.getWhiteLabelingLogo();
str=new ByteArrayInputStream(itemImage);
return SUCCESS;
}
public void setItemImage(byte[] itemImage) {
this.itemImage = itemImage;
}
public InputStream getStr() {
return str;
}
public void setStr(InputStream str) {
this.str = str;
}
public byte[] getItemImage() {
return itemImage;
}
}
在 index.jsp 我有这个:
<img src="<s:url value="ShowImageAction" />" border="0" width="100" height="100">
在 struts.xml 我有这个:
<action name="ShowImageAction">
<result name="success" type="stream">
<param name="inputName">str</param>
<param name="contentType">image/jpeg</param>
</result>
</action>
我做的不好是因为我什么都没有。非常感谢