0
im struts 2的新增功能,並詢問是否有方法將變量參數傳遞到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,這是不是我想要的東西=(
你的getter應該是'getFileName',它的名字是否正確? –
恥辱對我來說,我花了幾個小時在錯誤的時間在我眼前= $ 非常感謝你它的工作 – wannas
新鮮的眼睛經常發現的東西立即:) –