/
EtagViewRenderController.kt
36 lines (31 loc) · 1.16 KB
/
EtagViewRenderController.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.arahansa.chapter2
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.context.request.WebRequest
/**
* https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#filters-cors
* https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-caching-etag-lastmodified
*/
@Controller
@RequestMapping("/chap2")
class EtagViewRenderController {
fun getEtag(): Long {
return 1L
}
@GetMapping("/etagview")
fun eTagTest(webRequest: WebRequest, name: String?, model: Model): String? {
val eTag: Long = getEtag()
if (webRequest.checkNotModified(eTag)) {
println("여기서 eTag널처리하는 부분이 들어가긴하겠죠..")
return null
}
model.addAttribute("name", name)
return "chap2/etagview"
}
@GetMapping("/originalview")
fun eTagTestNo(webRequest: WebRequest, name: String?, model: Model): String {
return "chap2/etagview"
}
}