以缩略图形式显示图像,然后下载Struts2

问题描述:

我正在尝试查看不在应用程序中但在其他驱动器中的图像。但我没有得到输出,我的行动没有得到调用。请指出错误。以缩略图形式显示图像,然后下载Struts2

JSP

<img src="<s:url var="profilePic" action="download"> 
        <s:param name="fid" value="test"/> 
        </s:url>" alt="logo" /> 

行动

 public class DownloadAction extends ActionSupport implements ServletRequestAware{ 
     private HttpServletRequest req; 

    @Action(value="download", results = { @Result(location="/index.jsp", type="stream", 
      params={"contentType","application/octet-stream","inputName","fileInputStream","bufferSize","1024"} 
      ), @Result(name="input", location="/index.jsp") 
     }) 
    public String download() throws Exception { 
      //File theFile = new File("c:\\shareapp\\admin",getReq().getParameter("fid")); 
     try{ 
      System.out.println("inside"); 
       FileInputStream inputStream=FileUtils.openInputStream(new File("c:\\shareapp\\admin",getReq().getParameter("fid"))); 
     }catch(Exception ce) 
     { 
      System.out.println(ce); 
     } 
      return SUCCESS; 
     } 
//getters & setters 

其实我想要的文件被加载缩略图。任何帮助表示赞赏。

+0

你**觉得**你的动作没有被调用?为什么不测试它然后问一个问题。 – 2013-04-24 16:30:54

+0

我用这个System.out.println(“inside”);并没有在控制台上输出,所以它没有被称为 – Aadam 2013-04-24 16:35:00

+0

对不起,并在更改的问题:) – Aadam 2013-04-24 16:35:30

如果要使用<s:url>标签,请删除var属性。如果<s:param>value属性是字符串,则使用'来表明它是字符串。

<img src="<s:url action="download"> 
      <s:param name="fid" value="'test'"/> 
      </s:url>" alt="logo" /> 
+0

谢谢你,雅我的工作和var是问题 – Aadam 2013-04-25 09:52:37