Yaf route configuration rules

Source: Internet
Author: User

When using the default routing of the framework for access, there may be some problems. This part cannot view the source code and can only be analyzed by speculation.

If the project has multiple modules, it is clear that the default static route using yaf cannot meet the requirements.

The default yaf configuration is as follows:

application.baseUri=”/======Index

 

Explain the functions in turn

Application. baseUri = "/" indicates that the domain is followed by the content to be parsed. If our application is accessed through folder, baseUri is/a. Therefore, the purpose of this baseuri is to indicate which parts need to be processed by the route and which parts are actually paths.

The default module is Index,

Application. dispatcher. defaultModule = Index

This statement is tested and found to be invalid. That is to say, the default module cannot be modified through configuration,

While

Application. dispatcher. defaultController = Index

Application. dispatcher. defaultAction = index

That is, the default controller and default action can be assigned accordingly.

Then, add a module for the route. When creating a new module, notify the added module to the route so that the route can perform this operation when requesting a new module.

 

Application. modules = Index uses this sentence. If you want to add the new module Myoo, you must write it after the Index, Myoo ().

Change to application. modules = Index, Myoo


 

The routing of the original framework is basically a default module, but the default controller and action cannot be changed to a dead index.

The advantage of this situation is that each module has a specified controller and action. To access the index controller indexaction of the myoo module, you only need to write a module name myoo.

Currently, yaf cannot. The default mudule is writable, while the default controller and action are used by the default module. If you want to access myoo/index/, you can only write all of them, instead of writing only myoo, writing only myoo without the controller and action, the routing still does not know where the final destination is, and will not be found from the module, myoo is parsed into a controller of the default module, and then a 404 error is thrown,

This is enough.

However, I think it is a bug that the default module cannot be changed, because if it cannot be changed, why should we configure this configuration item.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.