Home > Backend Development > PHP Tutorial > Find the solution to synchronize the front-end URL with the back-end in the MVC framework, mvcurl_PHP tutorial

Find the solution to synchronize the front-end URL with the back-end in the MVC framework, mvcurl_PHP tutorial

WBOY
Release: 2016-07-13 10:21:10
Original
1051 people have browsed it

Find the solution to synchronize the front-end URL and the back-end in the MVC framework, mvcurl

Basic idea:

First use URL tags to generate complete URL characters, the front-end dynamic parameters are filled in with adapters first, and finally the dynamic parameters are replaced using regular matching.

This method can be applied in various MVC frameworks, which is wonderful.

No nonsense, just code.

<span>var</span> url = "{url app=xxxxn&act=yyy&id=[0]}"<span>;
url </span>= url.format({$id});
Copy after login

<span>//</span><span>String.format 同时匹配[](){}内容方式</span>
<span>if</span> (!<span>String.prototype.format) {
    String.prototype.format </span>= <span>function</span><span> () {
        </span><span>var</span> args =<span> arguments;
        </span><span>var</span> tag = ''<span>;
        </span><span>return</span> <span>this</span>.replace(/(\{|\(|\[)(\d+)(\}|\)|\])/g, <span>function</span><span> (match, m0,m1,m2) {
            tag </span>= m0+<span>m2;
            </span><span>if</span>(tag=='()' || tag == '{}' || tag == '[]') <span>return</span> <span>typeof</span> args[m1] != 'undefined'? args[m1]: (m0+m1+<span>m2);
        });
    };
}</span>
Copy after login

The method of the String object has been changed using the prototype method above, which can be rewritten appropriately and turned into a general function parameter transfer.

How to prevent the address bar from directly typing url to access the backend? The framework is spring mvc and the annotation method is used

Put the login information in the Session, and then judge, if (session==null) {jump to the login page}.

How does net mvc front-end interact with the backend

Basically, ajax is used to submit to the background or obtain data from the background.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/863230.htmlTechArticleFind the solution for synchronizing the front-end URL and the back-end in the MVC framework, mvcurl Basic idea: First use URL tags to generate complete URL characters, the front-end dynamic parameters are filled in with adapters first, and finally...
Related labels:
mvc
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template