6.2.6. Resource Mapping Handler

This handler provides the function to return the response without going through the business action. This function is used to download static resources through the Nablarch handler.

Important

The method of downloading static resources using this handler has disadvantages such as “a large amount of log is output” and “a server which is highly accessed, which places a heavy load on the application server”.

Therefore, using this handler for downloading static resources that do not need to go through the handler is not recommended. Download static resources using the function of the web container or web server, and use this handler only for contents that need to go through other handlers such as “authorization is required to be performed for contents download”.

This handler performs the following process.

  • Returns the response that performs static resource download

Important

This handler is mainly used in combination with the Request Handler Entry handler to realize the function of “download static resource in the case of specific extensions”.

For examples of the applications, see usage example of request handler entry.

The process flow is as follows. As shown in the figure, this handler does not call subsequent handlers.

../../../../_images/flow41.png

6.2.6.2. Module list

<dependency>
  <groupId>com.nablarch.framework</groupId>
  <artifactId>nablarch-fw-web</artifactId>
</dependency>

6.2.6.3. Constraints

Place this handler after the Internal Forward Handler
This handler can use the forward:// scheme provided by the function of the Internal Forward Handler. Therefore, this handler must be placed after the Internal Forward Handler.
Place this handler after the HTTP Response Handler
This handler can use the servlet://, file:// and classpath:// schemes provided by the function of the HTTP Response Handler. Returns a 404 (Not Found) response when an error occurs. Therefore, this handler must be placed after the HTTP Response Handler to process these responses.

6.2.6.4. Download static resources

When downloading static resources, which is the main use of this handler, configure the two properties baseUri and basePath as follows.

<!-- Handler that downloads static resources for image file -->
<component name="imgMapping"
           class="nablarch.fw.web.handler.ResourceMapping">
  <property name="baseUri" value="/"/>
  <property name="basePath" value="servlet:///"/>
</component>

The meaning of each configuration item is as follows

Configuration item Description
baseUri URL to be processed. If it does not match this URL,
the handler returns a HTTP status 404 (Not Found) response.
basePath Base URL of the response if it matches baseUri.
If the schema specification is omitted, servlet:// schema is used.

However, if the handler with the above configuration is just added to the handler queue, all URLs sent to the server are processed as static resources. In other words, all handlers after this handler in the handler queue will not be executed.

Therefore, this handler must be used in combination with Request Handler Entry as described in Usage example of this handler.