Loading...
Spring Framework Reference Documentation 7.0.2의 Processing의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
DispatcherServlet은 다음과 같이 request를 처리합니다:
WebApplicationContext가 검색되어 request에 attribute로 bind되며, controller와 process의 다른 element들이 이를 사용할 수 있습니다. 기본적으로 DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE key 아래에 bind됩니다.
locale resolver가 request에 bind되어, process의 element들이 request를 처리할 때 사용할 locale을 resolve할 수 있게 합니다 (view를 rendering하고, data를 준비하는 등). locale resolving이 필요하지 않다면, locale resolver가 필요하지 않습니다.
multipart file resolver를 지정한 경우, request는 multipart가 있는지 검사됩니다. multipart가 발견되면, request는 process의 다른 element들에 의해 추가로 처리될 수 있도록 MultipartHttpServletRequest로 wrapping됩니다. multipart handling에 대한 추가 정보는 Multipart Resolver를 참고하십시오.
적절한 handler가 검색됩니다. handler가 발견되면, handler와 연관된 execution chain (preprocessor, postprocessor, controller)이 실행되어 rendering을 위한 model을 준비합니다. 또는, annotation이 적용된 controller의 경우, view를 반환하는 대신 HandlerAdapter 내에서 response를 rendering할 수 있습니다.
model이 반환되면, view가 rendering됩니다. model이 반환되지 않는 경우 (아마도 preprocessor나 postprocessor가 request를 가로채서, security상의 이유 등으로), view는 rendering되지 않습니다. 이는 request가 이미 처리되었을 수 있기 때문입니다.
WebApplicationContext에 선언된 HandlerExceptionResolver bean들은 request processing 중에 발생한 exception을 resolve하는 데 사용됩니다. 이러한 exception resolver들은 exception을 처리하는 logic을 customize할 수 있게 해줍니다. 더 자세한 내용은 Exceptions를 참고하십시오.
HTTP caching을 지원하기 위해, handler들은 WebRequest의 checkNotModified 메서드를 사용할 수 있으며, HTTP Caching for Controllers에 설명된 대로 annotation이 적용된 controller를 위한 추가 option들을 함께 사용할 수 있습니다.
web.xml 파일의 Servlet 선언에 Servlet initialization parameter (init-param element)를 추가하여 개별 DispatcherServlet instance를 customize할 수 있습니다. 다음 table은 지원되는 parameter를 나열합니다:
| Parameter | Explanation |
|---|---|
contextClass | 이 Servlet에 의해 인스턴스화되고 local하게 configure될 ConfigurableWebApplicationContext를 구현하는 class입니다. 기본적으로 XmlWebApplicationContext가 사용됩니다. |
contextConfigLocation | context가 어디에서 발견될 수 있는지를 나타내기 위해 contextClass에 의해 지정된 context instance에 전달되는 string입니다.<br>이 string은 여러 context를 지원하기 위해 잠재적으로 여러 개의 string (comma를 delimiter로 사용)을 포함할 수 있습니다.<br>bean이 중복 정의된 여러 context location의 경우, 가장 마지막 location이 우선권을 가집니다. |
namespace | WebApplicationContext의 namespace입니다. 기본값은 [servlet-name]-servlet입니다. |
throwExceptionIfNoHandlerFound | request에 대해 handler가 발견되지 않았을 때 NoHandlerFoundException을 던질지 여부입니다.<br>이 exception은 이후 HandlerExceptionResolver (예를 들어, @ExceptionHandler controller method를 사용하여)에 의해<br>catch되어 다른 exception과 마찬가지로 처리될 수 있습니다.<br>6.1부터 이 property는 true로 설정되며 deprecated되었습니다.<br>default servlet handling이<br>함께 configure된 경우, resolve되지 않은 request는 항상 default servlet으로 forward되며<br>404는 절대 발생하지 않는다는 점에 유의하십시오. |
Table 1. DispatcherServlet initialization parameters
Servlet Config
Path Matching