본문 바로가기
with my rubber duck/errors

Spring Security multipartfile 업로드 안될때 해결

by stilinski 2022. 6. 16.
728x90

....
어제까지만해도 잘됐던 multipartfile로 이미지업로드가 security 넣고나서 갑자기 안된다.

값이 다 안들와지는건가 로그를 찍어보니

다른거는 잘 나오는데 사진만 null이다.


좀 검색해보니 form에 action url에

?${_csrf.parameterName}=${_csrf.token}

이걸 붙이라고 나온다.

즉 이런모양

근데....

....?
이런식으로 붙이는 게 아닌가.? 보다.

이렇게 해도 안됨.



더 검색해보니 다들 csrf토큰 사용하려면 web.xml에 필터를 추가하래
아니 springboot 플젝이라서 web.xml없다고
그냥 만들어서 해야하나...
이렇게 불편하게 해놨을리가 없는데..
근데 편한방법 못찾음.
결국 사방팔방 돌아다니다 xml의 filter를 자바코드로 빈으로 등록하는 법을 찾게되고...(그런 방법이 존재하는지도 몰랐음..ㅋㅋㅋ)


https://stackoverflow.com/questions/19825946/how-can-i-add-a-filter-class-in-spring-boot/30658752#30658752

 

How can I add a filter class in Spring Boot?

Is there any annotation for a Filter class (for web applications) in Spring Boot? Perhaps @Filter? I want to add a custom filter in my project. The Spring Boot Reference Guide mentioned about

stackoverflow.com


https://goldswan.tistory.com/43

 

[Spring]CSRF 토큰이 Multipart 이미지 전송에서 인식되지 않는 이슈 해결 방법(Error Message : Invalid CSRF To

서론 Spring 프로젝트를 진행하던 중 이미지 전송을 위해 enctype="multipart/form-data"인 form 태그 안에 아래와 같이 CSRF 토큰을 기술해도 Invalid CSRF Token 'null' was found on the request parameter '_c..

goldswan.tistory.com


필터를 등록해주니 csrf토큰도 없어도 된다.
아니 원래 필터가 필요했던건가?
아니지 시큐리티 없었을땐 잘됐어..
뭘까

728x90

댓글