struts的配置如下:
<package name="default" extends="struts-default">
<action name="down" class="test.struts.Down">
<result name="down" type="stream">
<param name="contentType">application/octet-stream</param>
<param name="inputName">bis</param>
<param name="contentDisposition">attachment;filename="${downloadFileName}"</param>
<param name="bufferSize">100000</param>
</result>
</action>
</package>
public InputStream bis;
public String downloadFileName;
//下面是getter and setter方法省略了
public String download() {
try{
File file=new File("C:\\12.doc");
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bis=new BufferedInputStream(fis);
downloadFileName="12.doc";
System.out.println();
}catch(Exception e){
e.printStackTrace();
}
return "down";
运行时会报
No result defined for action test.struts.Down and result down
这个错误,,找了半天是action的name属性的原因,,改成其他的就好了,,不过不知道为什么