0

嗨,我按照我在这里看到的一个例子,但我的结果很糟糕,我有这个ShowImageAction

public static void execute() throws RemoteException {  

HttpServletResponse response = ServletActionContext.getResponse();  
response.reset();  
response.setContentType("multipart/form-data");   
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(); 
System.out.println(itemImage); 
OutputStream out; 

try { 
    out = response.getOutputStream(); 
    out.write(itemImage);  
       out.flush();  
       out.close(); 
} catch (IOException e) { 
    // TODO Auto-generated catch block 
    e.printStackTrace(); 
} 




} 

哪里getWhiteLabelingLogo(); 将blob返回给我byte[],然后在我的jsp上我有这个:

<img src="<s:url value="ShowImageAction" />" border="0" width="100" height="100">  

为什么它不起作用?这样对吗?。非常感谢

4

1 回答 1

0

Dave 提到的流结果类型需要实现的基础知识:

strusts.xml:

<action name="yourImageStreamAction">
    <result name="success" type="stream">
        <param name="inputName">inputStream</param>
    </result>
</action>

行动:

private InputStream inputStream = null;

public String execute() {
   //set inputStream from itemImage.  
   //I don't know what itemImage is, so I'll leave that to you
   return SUCCESS;
}

public InputStream getInputStream() {
   return this.inputStream;
}
于 2012-07-29T23:17:42.290 回答