0
我有要求從文件系統獲取圖像並在瀏覽器中顯示它的要求。我曾試圖到現在的代碼如下所示:上傳圖像並在瀏覽器中彈出webflow
的.jsp代碼:
<formspring:form enctype="multipart/form-data" modelAttribute="onlinePurchase">
Please select a file to upload : <input type="file" name="multipartFileUpload" id="multipartFileUpload" />
<div class="submit">
<input type="submit" id="upload" name="_eventId_upload"
value="Upload Image" />
</div>
</formspring:form>
控制器代碼:
public void saveImage(OnlinePurchase onlinepurchase,
MultipartFile multipartFile) {
try {
onlinepurchase.setContent(multipartFile.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
onlinepurchase.setContentSize(new Long(multipartFile.getSize())
.intValue());
onlinepurchase.setContentType(multipartFile.getContentType());
onlinepurchase.setFilename(multipartFile.getOriginalFilename());
}
flow.xml代碼:
<view-state id="onlinePurchaseStep1" view="onlinepurchase/onlinepurchaserequest-step-1"
model="onlinePurchase">
<on-render>
<evaluate expression="oPAction.initialize" />
</on-render>
<transition on="submit" to="onlinePurchaseStep1" validate="false">
<evaluate expression="oPAction.cropImage" />
</transition>
<transition on="upload" to="onlinePurchaseStep1" validate="false">
<evaluate
expression="oPAction.saveImage(onlinePurchase,requestParameters.multipartFileUpload)"
result="" result-type="" />
</transition>
<transition on="success" to="onlinePurchaseStep2">
<evaluate expression="oPAction.addMedia" />
</transition>
<transition on="cancel" to="login" validate="false" />
</view-state>
問題是不會調用saveImage(OnlinePurchase onlinepurchase,String multipartFile)方法。 任何建議表示讚賞。
沒有堆棧跟蹤可用? –