There is a problem when I upload some files using multipartfile, I get "Access is denied".

config:

@Override protected void configure(HttpSecurity http) throws Exception { http .csrf().disable() .formLogin().disable() .cors() .and() .httpBasic() .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .addFilterBefore(sessionFilter(), SessionManagementFilter.class) .authorizeRequests() .antMatchers( "/", "/login", "/registration", "/resources/**", "/error/*", "/language", "/favicon.ico", "/ru/**", "/en/**", "/ua/**" ) .permitAll() .anyRequest().authenticated() .and() .exceptionHandling() .accessDeniedPage("/403") .authenticationEntryPoint(unauthorizedHandler()) .and() .logout() .logoutSuccessHandler(logoutSuccessHandler()); } 

controller:

 @RequestMapping(value = "/libs/upload", method = RequestMethod.POST) public String uploadLibFile( @RequestParam MultipartFile file, HttpServletRequest request ) throws IOException { fileService.uploadLibFile(request.getServletContext().getRealPath("/"), file); return "redirect:" + getPathWithLocale("admin/libs/general"); } 

jsp:

 <form enctype="multipart/form-data" action="/${pageContext.response.locale}/admin/libs/upload" method="POST"> <p> <input name="file" type="file"> </p> <p> <input type="submit" value="Upload files"> </p> </form> 

What is the problem, I can not figure it out.

  • Is authentication required to upload files, and what does some mean? - Roman C
  • The fact of the matter is that it should not be required, but I found the information that such a problem exists and is related to MultipartFilter - Andrii Torzhkov
  • What will happen if you change the type of content, it will be skipped? - Roman C
  • Do you mean content-type? - Andrii Torzhkov

0