6.2.11. HTTP Request Dispatch Handler¶
Table of contents
This handler delegates processing to an action that describes the process to be performed for each function of the application.The delegated class and method are determined by the accessed URL.The URL format is assumed to be as follows for the dispatch using this class.
- URL format
Each of the parts enclosed by <> in the above format have the following meanings.
|baseUri||Relative path from the context root|
Implement method name of action class as HTTP method + method name.
When the http method is
Refer to Configure dispatch settings on how to specify the mapping between URL and action.
Since the URL is decided based on the class name in the HTTP request dispatch handler, flexible URL cannot be used.
For example, to use
/user/index as a URL, the class name has to be configured as
This violates the general Java conventions for class name and is not recommended.
Therefore, rather than using this handler, the use of Routing Adapter is recommended that can flexibly configure the mapping between URL and action class.
This handler performs the following process.
- Analyzes the URI and calls the method of the corresponding action.
The process flow is as follows.
<dependency> <groupId>com.nablarch.framework</groupId> <artifactId>nablarch-fw-web</artifactId> </dependency>
- Should be placed at the end of the handler queue
- This handler does not call subsequent handlers. Therefore, place this handler at the end of the handler queue.
When using this class, baseUri described above and package (base package) in which the action is placed are required to be configured.
Below is an example of configuring baseUri to
action and base package to
<component name="packageMapping" class="nablarch.fw.web.handler.HttpRequestJavaPackageMapping"> <property name="baseUri" value="/action/"/> <property name="basePackage" value="jp.co.tis.nablarch.example"/> </component>
A dispatch example for the above configuration is shown below.
|Dispatch destination class:|
Actions can be placed across multiple packages. In this case, configure the base package described in Configure dispatch settings above to the package where all Actions are placed, and describe the path from the base package to the corresponding Action in the URI class name.
An example of class allocation and URL mapping is shown below.