action的public class ExportExcelAction extends ActionSupport
{
private InputStream excelStream;
private String fileName;
/**
* @return the excelStream
*/
public InputStream getExcelStream()
{
return excelStream;
} /**
* @param excelStream the excelStream to set
*/
public void setExcelStream(InputStream excelStream)
{
this.excelStream = excelStream;
} /**
* @return the fileName
*/
public String getFileName()
{
// try
// {
// fileName = new String(fileName.getBytes(),"UTF-8");
// } catch (UnsupportedEncodingException e)
// {
// e.printStackTrace();
// }
return fileName;
} /**
* @param fileName the fileName to set
*/
public void setFileName(String fileName)
{
this.fileName = fileName;
} @Override
public String execute() throws Exception
{
excelStream = new FileInputStream(new File("c:/1.xls"));
System.out.println(excelStream);
return SUCCESS;
}
}
struts.xml的
<action name="exportExcelAction" class="cn.com.petrochina.struts2.action.ExportExcelAction">
<result name="success" type="stream"></result>
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}"</param>
<param name="bufferSize">100000</param>
<result name="input">/login.jsp</result>
</action>
jsp上就一个下载按钮,然后按下会报错:Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.是我什么地方配置错了么? 大家帮忙看看吧
{
private InputStream excelStream;
private String fileName;
/**
* @return the excelStream
*/
public InputStream getExcelStream()
{
return excelStream;
} /**
* @param excelStream the excelStream to set
*/
public void setExcelStream(InputStream excelStream)
{
this.excelStream = excelStream;
} /**
* @return the fileName
*/
public String getFileName()
{
// try
// {
// fileName = new String(fileName.getBytes(),"UTF-8");
// } catch (UnsupportedEncodingException e)
// {
// e.printStackTrace();
// }
return fileName;
} /**
* @param fileName the fileName to set
*/
public void setFileName(String fileName)
{
this.fileName = fileName;
} @Override
public String execute() throws Exception
{
excelStream = new FileInputStream(new File("c:/1.xls"));
System.out.println(excelStream);
return SUCCESS;
}
}
struts.xml的
<action name="exportExcelAction" class="cn.com.petrochina.struts2.action.ExportExcelAction">
<result name="success" type="stream"></result>
<param name="contentType">application/vnd.ms-excel</param>
<param name="inputName">excelStream</param>
<param name="contentDisposition">attachment;filename="${fileName}"</param>
<param name="bufferSize">100000</param>
<result name="input">/login.jsp</result>
</action>
jsp上就一个下载按钮,然后按下会报错:Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.是我什么地方配置错了么? 大家帮忙看看吧
2012-9-17 16:34:33 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.打印是有输入流的,可是为啥会说没有呢,真搞不明白了
严重: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
已经说的很明白了,check the <param name="inputName"> tag也就是说action中没有定义这个inputName,或者说这个名称没有对应上你action中定义的名称。
已经定义了啊,xml中是 <param name="inputName">excelStream</param>
action中有对应的 private InputStream excelStream;
谢谢你,不过不是jsp页面的问题期待其他朋友的帮助
这个你试过么? xml中不配置不行吧