Your jsp uploadFile.jsp must have a proper enctype:
Code:
<form:form commandName="uploadFileModel" enctype="multipart/form-data">
Upload file: <input type="file" name="file"/>
</form:form>
and a flow sample:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="uploadFileModel" class="yourpackage.UploadFileModel"/>
<view-state id="uploadFile" model="uploadFileModel">
<transition on="ok" to="finish" >
<evaluate expression="yourService.doSomethingWithTheFileContent(uploadFileModel.fileContent)"/>
<transition on="cancel" to="finish" bind="false"/>
</view-state>
<end-state id="finish"/>
</flow>
If you are using swf2.x there are some problems with the binding from MultipartFile to byte[]. So as a temporary solution you can use a model like:
Code:
class UploadFileModel implements Serializable {
private byte[] fileContent;
public byte[] getFileContent() {
return fileContent;
}
public void setFile(MultipartFile file) {
this.fileContent = file.getBytes();
}
}
When the bug http://jira.springframework.org/browse/SWF-696 will be resolved probably you'll have a direct binding to byte[] and the MultipartFile will disappear.
Hope that this will help.