0
후 나는 는 스프링 MVC : 예외도 200 OK 응답
@RequestMapping(value="fetchprofilepics/{profileId}/{column}/{random}",method=RequestMethod.GET)
public void fetchProfilePhoto(HttpServletResponse response, @PathVariable String profileId, @PathVariable String column, @PathVariable String random) throws IOException, ContentDeletedException
{
BufferedOutputStream bufferedOutputStream = null;
try {
//.............
bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
ByteBuffer byteBuffer = imgService.getProfilePhoto(cqlSession, column, profileId);
if(byteBuffer==null) throw new ContentDeletedException();
byte bytes[] = new byte[byteBuffer.remaining()];
byteBuffer.get(bytes, 0, bytes.length);
bufferedOutputStream.write(bytes);
} catch (IOException ex) {ex.printStackTrace();}
finally{if(bufferedOutputStream!=null) bufferedOutputStream.close();}
throw new ContentDeletedException();
}
byteBuffer
이 null
이 tomcate 로그에 ContentDeletedException
발생하지만, 브라우저 콘솔에서 여전히 200OK
반응을 보여 경우 컨트롤러
왜? 200 OK
상태를 던져서는 안됩니다.
ContentDeletedException가 @ExceptionHandling 표시되지 않거나 오류에 대한 web.xml의 설정을 가지고?하지만이 발생되고있다 exeption이 ContentDeletedException'' – Koitoer
당신의 try catch 블록에 던져 캐치되고있는 것 같다 바람둥이 console.'IOException' 던져하지 않습니다 – manish