Spring 使用带freemarker的文件上载时的HTTP状态500

Spring 使用带freemarker的文件上载时的HTTP状态500,spring,spring-mvc,Spring,Spring Mvc,我正在尝试使用spring和hibernate技术在我的freemarker页面(ftl文件)中添加图像上载- 这是我每次运行应用程序时遇到的错误: HTTP状态500-服务器 遇到一个内部错误() 阻止它实现这一目标 请求 这是代码: 1-POM文件: <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</arti

我正在尝试使用spring和hibernate技术在我的freemarker页面(ftl文件)中添加图像上载- 这是我每次运行应用程序时遇到的错误:

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>
一定要不折不扣地遵守规则。通常,您是否使用
enctype
属性正确定义了
元素

<form method="post" action="/form" enctype="multipart/form-data">

如其他评论所述,需要日志来获取更多提示。如果没有写入特定的日志,请确保将记录器的阈值配置为较低的级别;虽然500代码应该与错误级别日志相关,但很少被过滤掉。仔细检查日志配置!:)


HTH

你能再发布一些错误日志吗?是的,我们需要服务器上的错误日志。如果是freemarker问题,根据我的经验,错误日志非常有用。没有异常或错误日志只显示:“HTTP状态500-服务器遇到内部错误(),无法完成此请求。”显示在浏览器中。。我不知道问题到底出在哪里。我如何才能获得错误日志?这与FreeMarker没有任何关系。+1,我们的学员也有同样的问题,这就是解决方案!顺便说一句,日志中也没有任何内容(WebLogic 10.3)
<input type="file" id="image" name="image" value="">
@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";

}
<form method="post" action="/form" enctype="multipart/form-data">