我对struts 2很新,我想问是否有办法将变量参数传递给struts 2注释。
这是我已经做过但没有运气的事情
public class DownloadFileAction extends ModuleGenericClass{
private InputStream inputStream;
private String fileName;
@Action(value="/downloadFile",results={
@Result(name="success",type="stream",params = {
"contentType",
"application/octet-stream",
"inputName","inputStream",
"bufferSize","1024","contentDisposition",
"filename=\"${fileName}\""})
})
public String execute() throws Exception {
fileName = "testing";
inputStream = //myInputStream
return SUCCESS;
}
public void setCourrierId(String courrierId) {
this.courrierId = courrierId;
}
public String getfileName() {
return fileName;
}
public void setfileName(String fileName) {
this.fileName = fileName;
}
public InputStream getInputStream() {
return inputStream;
}
public void setInputStream(InputStream inputStream) {
this.inputStream = inputStream;
}
}
我在网上搜索但我发现只有xml Struts的解决方案,这不是我想要的=(
答案 0 :(得分:0)
您的文件名getter方法名称不正确,它应遵循JavaBean模式:
public String getFileName() { ... }
OGNL没有打电话给吸气者;动态参数在注释中工作,就像在XML中一样。