文件上传在Jetty下有效,但在Tomcat下无效

文件上传在Jetty下有效,但在Tomcat下无效,第1张

文件上传在Jetty下有效,但在Tomcat下无效

感谢@Bart,我得以找到以下简单的解决方案:

拦截方法中,使用@ModelAttribute而不是@RequestParam:

@RequestMapping(value = import_PAGE, method = RequestMethod.POST)public String recieveFile(@RequestParam("importType") String importType,        @ModelAttribute("file") UploadedFile uploadedFile, final HttpSession session){    MultipartFile multipartFile = uploadedFile.getFile();

其中UploadedFile是以下类:

public class UploadedFile{    private String type;    private MultipartFile file;    public String getType()    {        return type;    }    public void setType(String type)    {        this.type = type;    }    public void setFile(MultipartFile file)    {        this.file = file;    }    public MultipartFile getFile()    {        return file;    }}

它正在工作!

感谢大家的帮助。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5442342.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存