<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Spring MVC on 얼쑤 · Team Edo</title><link>https://team-edo.github.io/tags/spring-mvc/</link><description>Recent content in Spring MVC on 얼쑤 · Team Edo</description><generator>Hugo</generator><language>ko-kr</language><lastBuildDate>Thu, 29 Oct 2026 00:00:00 +0900</lastBuildDate><atom:link href="https://team-edo.github.io/tags/spring-mvc/index.xml" rel="self" type="application/rss+xml"/><item><title>단독 MockMvc에서 JWT가 비어 500이 난 이유</title><link>https://team-edo.github.io/posts/2026/10/mockmvc-principal-test-boundaries/</link><pubDate>Thu, 29 Oct 2026 00:00:00 +0900</pubDate><guid>https://team-edo.github.io/posts/2026/10/mockmvc-principal-test-boundaries/</guid><description>&lt;p>성장 화면 API의 단독 MockMvc 테스트를 작성하고 실행하니 정상 요청과 400을 기대한 요청이 모두 500으로 실패했습니다. 로그를 따라가 보니 컨트롤러의 &lt;code>@AuthenticationPrincipal jwt: Jwt&lt;/code>에 값이 들어오지 않았습니다. Kotlin은 non-null 매개변수에 &lt;code>null&lt;/code>이 넘어오는 순간 예외를 던졌고, 요청은 정작 검사하려던 코드까지 가지 못했습니다.&lt;/p>
&lt;h2 id="단독-테스트가-빠뜨린-연결을-채웠다">인자 해석기와 예외 처리기 등록&lt;/h2>
&lt;p>&lt;code>standaloneSetup&lt;/code>은 제가 넘긴 컨트롤러를 중심으로 작은 MVC 환경을 만듭니다. 실제 앱에서 쿠키를 읽고 JWT를 검증하는 보안 필터까지 자동으로 붙지는 않습니다. 요청에 인증 후처리기만 붙인 첫 테스트에서는 컨트롤러가 읽을 인증 정보가 비어 있었습니다.&lt;/p></description></item><item><title>HTTP 406에도 공통 오류 본문 적용하기</title><link>https://team-edo.github.io/posts/2026/10/keep-common-error-body-for-http-406/</link><pubDate>Wed, 28 Oct 2026 00:00:00 +0900</pubDate><guid>https://team-edo.github.io/posts/2026/10/keep-common-error-body-for-http-406/</guid><description>&lt;p>앱은 요청에 실패하면 HTTP 상태와 응답 본문의 &lt;code>result.errorCode&lt;/code>를 읽습니다. 컨트롤러가 거절한 요청에 공통 형식을 쓰더라도, Spring이 컨트롤러 호출 전에 예외를 처리하면 다른 형태의 본문이 내려갈 수 있습니다. 지원하지 않는 응답 형식을 요청해 406이 나오는 경우가 그 예였습니다.&lt;/p>
&lt;h2 id="상태와-헤더를-살리고-본문을-공통-형식으로-맞췄다">상태와 헤더를 유지한 공통 본문&lt;/h2>
&lt;p>필수 쿼리 파라미터가 없거나 값의 형식이 틀리면 Spring MVC가 400을 만듭니다. 공통 예외 처리기는 이때 앱이 사용하는 &lt;code>INVALID_REQUEST&lt;/code> 본문을 돌려줍니다. 405는 허용 메서드를 알려 주는 &lt;code>Allow&lt;/code> 헤더도 보존해야 합니다. 본문을 맞추면서 Spring이 이미 정한 상태와 헤더를 함께 전달한 이유입니다.&lt;/p></description></item></channel></rss>