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.