URL 인코딩과 관련된 문제가 있다고 생각합니다. 경로를 매개 변수로 전달하는 것이 좋다고 생각하지 않습니다. 데이터베이스에 ID를 전달하여 FileInputStream에서 다운로드하는 것이 안전합니다. 최소한 권한이 부여 된 파일을 다운로드하려고 할 때 사용자의 권한을 확인할 수 있습니다.
I는 다음과 같이 할 것 :
Action 클래스
public String download() throws Exception {
fileName = getFromDatabaseById(id);
try
{
fileInputStream = new FileInputStream(new File(FILE_FOLDER + filename));
}
catch(FileNotFoundException ex)
{
logger.error(this.getClass().getSimpleName() + ": File in " + FILE_FOLDER + filename + " cannot be found.");
return ERROR;
}
return DOWNLOAD;
}
그리고 당신의 struts.xml에서
<iterator list...
<a href="filedownload?id=%{id_in_the_database} </a>
</iterator...
<action name="filedownload" method="download" class="com.yourproject.filedownload">
<result name="download" type="stream">
<param name="contentType">application/octet-stream</param>
<param name="inputName">fileInputStream</param>
<param name="contentDisposition">attachment;filename=%{filename}</param>
<param name="bufferSize">4096</param>
</result>
<result name="error" type="redirectAction">erroraction</result>
</action>