Strange routing problems in the javascript-framework

Source: Internet
Author: User
I wrote a simple mvc framework. The configured route is very simple, such as modulecontrolleraction. When accessing localhost: 86appindexindex, you can render the view file. The problem arises. Access the page through a route such as appindexindex and write a simple mvc framework on the page. The configured route is very easy to use rules such as module/controller/action.
When accessing localhost: 86/app/index, you can render the view file.

The problem arises.

Access the page through a route such as app/index, and write a jump

Click to jump to the page

In this case, the browser browsing path may change to localhost: 86/app/index/demo/index.
But sometimes it can be accessed normally and changed to localhost: 86/demo/index.

Two differences are found: app/index and/app/index in href. Is there any way to better solve this routing problem?

Project source code in https://github.com/zhoujiangy ....

Reply content:

I wrote a simple mvc framework. The configured route is very easy to use rules such as module/controller/action.
When accessing localhost: 86/app/index, you can render the view file.

The problem arises.

Access the page through a route such as app/index, and write a jump

Click to jump to the page

In this case, the browser browsing path may change to localhost: 86/app/index/demo/index.
But sometimes it can be accessed normally and changed to localhost: 86/demo/index.

Two differences are found: app/index and/app/index in href. Is there any way to better solve this routing problem?

Project source code in https://github.com/zhoujiangy ....

This is the URL path problem. it has nothing to do with your route.

App/index is the relative path.

/App/index is the absolute path.

Similar to the file system path, for example:
If the current location is/a/B/c
So,
Href = "foo/bar" to jump to/a/B/foo/bar
Href = "/foo/bar" to jump to/foo/bar.

This is not determined by your framework routing, but by web standards.

Href = "/xxx" is different from href = "xxx/xxx ".

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.