2017-03-03 41 views
0

我正在使用Stormpath + Spring MVC。 我嘗試使用文件附件發送請求時遇到問題。Stormpath multipartFile

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) 

而且其顯示一個拒絕訪問錯誤...

如何解決這個問題?謝謝。

回答

0

我找到了解決方案。 春季安全擋住了去上傳...

在我的HTML表單此配置:

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

其作品對我來說...