我試圖使用spring和hibernate技術在我的freemarker頁面(ftl文件)中添加圖片上傳 - 這是我每次運行應用程序時發生的錯誤:使用freemarker上傳文件時的HTTP狀態500
HTTP狀態500 - 服務器 遇到內部錯誤(),該 阻止它履行這一 請求。
,這是代碼:
1-POM文件:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
2- APP-config.xml中:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
3- FTL文件:
<input type="file" id="image" name="image" value="">
4網絡控制器:
@RequestMapping(method= RequestMethod.POST)
public String post(Model model , HttpServletRequest req , HttpSession session,@RequestParam("image") MultipartFile multipartFile) throws IOException{
// transfer the uploaded image to the place where images exist in project
multipartFile.getBytes();
File destination = new File("/home/user/Pictures/" + multipartFile.getOriginalFilename());
multipartFile.transferTo(destination);
// delete the original uploaded image
destination.delete();
return "redirect:index";
}
你可以發佈一些更多的錯誤日誌? – 2010-12-13 11:10:44
是的,我們需要服務器上的錯誤日誌。如果這是一個自由標記問題,根據我的經驗,錯誤日誌非常有用。 – Andy 2010-12-13 16:05:52
沒有例外或錯誤日誌出現,只是:「HTTP狀態500 - 服務器遇到一個內部錯誤(),阻止它履行此請求。」在瀏覽器中出現..我不知道問題到底在哪裏。 – se7so 2010-12-15 12:45:23