https://blog.itkonekt.com/2018/06/27/server-sent-events-in-spring/
https://supawer0728.github.io/2018/03/15/spring-http-stereamings/
http://kwseo.github.io/2017/03/25/sse/
https://dzone.com/articles/spring-boot-server-sent-events-tutorial
https://golb.hplar.ch/2017/03/Server-Sent-Events-with-Spring.html
https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/sse-emitter.html
http://andang72.blogspot.com/2018/05/server-sent-events.html
- 스프링 컨트롤러에서 SSE 사용하기
스프링은 SseEmitter 불리우는 클래스를 사용하여 HTTP 응답을 text/event-stream 타입으로 리턴한다.
이를 위해서 아래와 같이 web.xml 파일에 sync-support 를 반드시 추가해주어야 한다.
(servelt dispatcher와 filter 모두 추가해줘야 함)
<!-- spring dispatcher 설정 (java configuration) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.sample.configuration.web.WebDispatcherServlet</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- spring session filter -->
<filter>
<filter-name>springSessionRepositoryFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>springSessionRepositoryFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
'spring' 카테고리의 다른 글
@RequestMapping value or url 가져오기 (0) | 2022.04.02 |
---|---|
ResourceUtils를 이용한 Access a File from the Classpath-classpath에 위치한 파일 절대경로 구하기 (0) | 2020.07.29 |
viewResolver 우선순위 (0) | 2018.08.08 |
엑셀 업로드 & 다운로드 (0) | 2018.07.02 |
메일 보내기 (0) | 2018.06.15 |