Stormpath multipartFile

时间:2017-03-03 20:11:19

标签: spring spring-mvc stormpath

我正在使用Stormpath + Spring MVC。 当我尝试发送带有文件附件的请求时,我遇到了一个问题。

public ModelAndView insert(@RequestParam("files") MultipartFile files[], @Valid @ModelAttribute("ordemServico") OrdemServico ordemServico,
                               BindingResult result, Model model) throws IOException {

但我在下面得到了这个错误......

2017-03-03 17:00:34,395 ERROR [qtp504672873-22] c.s.s.c.StormpathAuthenticationEntryPoint Couldn't resolve content type
com.stormpath.sdk.servlet.http.UnresolvedMediaTypeException: No MediaType could be resolved for this request (text/css,*/*;q=0.1) and the configured producesMediaTypes settings (application/json,text/html). The ContentNegotiationResolver was not able to come up with a valid MediaType.
    at com.stormpath.sdk.servlet.filter.DefaultContentNegotiationResolver.getContentType(DefaultContentNegotiationResolver.java:59)

它显示访问被拒绝错误...

如何解决这个问题?感谢。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。 Spring Security阻止了上传......

使用我的html格式的配置:

<form method="POST" action="XXX?${_csrf.parameterName}=${_csrf.token}" enctype="multipart/form-data">

它适合我...