转自:http://blog.csdn.net/wnczwl369/article/details/7483290 转自:http://hi.baidu.com/c2_sun/item/934a542518c6ecc5a5275aad struts.xml文件配置: <span style="font-size:16px;"><?xml version="1.0" encoding="UTF-8" ?> <!DOCT…
今天在用struts2就行文件下载时出现如下错误: Servlet.service() for servlet default threw exception java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [imageStream] in the invocation stack. Check the <param name="inputName">…
成功代码: 前台界面jsp: <a style="text-decoration:none;" href="<%=path %>/main/frontNewsAction_downloadFile.action?fileName=<s:property value="fileTitle"/>">下载</a> Action文件:private String fileName;//get set方法 p…
struts.xml文件配置: <span style="font-size:16px;"><?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apac…
使用Struts2做一个简单的文件下载. 首先,导包,写配置文件就不说了. 进入主题. 文件下载操作类:FileDownload.java import java.io.InputStream; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class FileDownload extends ActionSupport{  private…
<!--struts.xml配置--> <action name="download" class="com.unmi.action.DownloadAction"> <result name="success" type="stream"><!--type 为 stream 应用 StreamResult 处理--> <param name="contentTy…
转自:http://blog.csdn.net/ctrl_shift_del/article/details/6277340 ServletActionContext.getServletContext().getResourceAsStream("/"+tempfile); 这是java加载资源的方法,所谓资源,实际上是任何一个文件,但特别的 是,getResourceAsStream这个方法不使用绝对路径,而是使用相对于classpath环境变量的相对路径. 所 以,如果写:  g…
Struts2极大的简化了文件上传和下载,本文将主要介绍一下Struts2文件下载的实现1.功能主要是,在下载页面点击下载后,则下载相应的文件 2.代码部分jsp页面downloadPage:<body><!--该页面主要就是一个超链接,点击进入DownloadAction,并传递三个参数:原文件的名字,文件类型,显示的下载文件名--><a href="${pageContext.request.contextPath}/download?res=example.p…
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE html> <html> <head> <meta charset…
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="/struts-tags" prefix="s"%> <!DOCTYPE html> <html> <head> <meta charset…