永发信息网

Can not find a java.io.InputStream with the name [inputStream] in the invocation stack.

答案:2  悬赏:50  手机版
解决时间 2021-03-04 22:38
  • 提问者网友:沉默菋噵
  • 2021-03-04 00:08
Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the tag specified for this action.
这个错误在网上查了很多,都说是路径问题,我的struts2配置是用注解方式写的,
action:
private HumanService humanService = null;
private InputStream excelStream;
get,set方法.......
@Action(value = "/HR/Data/excel", results = { @Result(name = "excel", type = "stream") }, params = {
"contentType", "application/vnd.ms-excel", "contentDisposition",
"attachment;filename=export.xls", "inputName", "excelStream" })
public String excel() throws Exception {
StringBuffer excelBuf = new StringBuffer();
excelBuf.append("编号").append("\t").append("身份证号").append("\t").append(
"一卡通号").append("\t").append("定级工资").append("\t").append("入职日期")
.append("\t").append("备注").append("\n");
List list1 = humanService.listHumans();
for (int i = 0; i < list1.size(); i++) {
HumanInfo humanInfo = (HumanInfo) list1.get(i);
excelBuf.append(humanInfo.getHuman_ID()).append("\t").append(
humanInfo.getHuman_IdNo()).append("\t").append(
humanInfo.getHuman_Bank()).append("\t").append(
humanInfo.getHuman_Percentage()).append("\t").append(
humanInfo.getHuman_EntryDate()).append("\t").append(
humanInfo.getHuman_State()).append(
"\n");
}
// excelBuf.append("Thinking in
// Java").append("\t").append("2001").append("\t").append("Eckel").append("\n");
// excelBuf.append("Spring in
// action").append("\t").append("2005").append("\t").append("Rod").append("\n");
String excelString = excelBuf.toString();
// logger.debug("result excel String: " + excelString);
excelStream = new ByteArrayInputStream(excelString.getBytes(), 0,
excelString.length());
return "excel";

}
jsp页面: onClick="javascript:window.location.href='excel.action'" />
希望大家可以帮帮忙,困扰很久了
最佳答案
  • 五星知识达人网友:怙棘
  • 2021-03-04 01:20
要什么功能就对着电脑喊,会有那么一天电脑通人性了,就自动帮你改好了。
全部回答
  • 1楼网友:舍身薄凉客
  • 2021-03-04 01:52
空指针,做一个判断,当不为空的时候才进行操作。 !=null
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯