简体   繁体   中英

cppcms url mapping in template files

When I add this rout to my server

server::server(cppcms::service &srv) : cppcms::aplication(srv)
{
    dispacher().assign("/(\\d+)/get/(\\w+)", &server::get, this, 1, 2);
}
  1. How can I assign this rout with mapper().assign() to be able to use routs as server/1/get/hello or server/2/get/hello ?
  2. How can I use this rout in template file with url?

<% url "1/get" using [a variable] %> does work?

First of all take a look on: http://cppcms.com/wikipp/en/page/cppcms_1x_tut_url_mapping

What you are missing is mapper:

mapper().assign("get","/{1}/get/{2}");  

And than

<% url "get" using [a variable for number], [a variable for text] %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM