Uncaught SyntaxError: Unexpected token < in JSON at position 20

고라니·2022년 3월 3일
0

회원가입 - 닉네임 중복 체크.do 비동기 통신 웹 개발 도중, ajaxCall 응답 결과로 에러가 계속 나와서 console.log(error)를 찍어보니, 다음과 같은 오류 메세지가 나왔다.

Uncaught SyntaxError: Unexpected token < in JSON at position 20

그리고 Spring (백단) Console
SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 이 메세지를 보고

spring/context-security.xml을 바로 가봤더니 해답이 나왔다.

<http pattern="/user/**" auto-config="true" use-expressions="true" authentication-manager-ref="authenticationManager" security-context-repository-ref="reloadableSecurityContextRepository">
이하 생략
<intercept-url pattern="/user/duplicateIdChk.do" access="isAnonymous()"/>
<intercept-url pattern="/user/**" access="isAuthenticated()"/>
이하포트, 로그인,아웃처리 커스텀필터등등생략
</http>

내가 하려는 부분도 isAnonymouse() 를 걸어줘야 제대로 스프링 통신이 가능한 것이었다.

<intercept-url pattern="/user/duplicateUserNckNmChk.do" access="isAnonymous()"/>

한 줄 추가해주니 해결!

에러 결과들이 너무 방대해서 조금 힘들었음...

profile
공부를 열심히 하는 학부생

0개의 댓글