By default application::main() returns a 404 page if it does not find any dispatcher for a given url: |
|
void application::main(std::string url) { |
if(!dispatcher().dispatch(url)) { |
response().make_error_response(http::response::not_found); |
} |
} |
|
|
To create your own 404 page, you must override the default application::main(). |
|
void myApplication::main(std::string url) { |
if (!dispatcher().dispatch(url)) { |
// Set the 404 status. |
response().status(http::response::not_found); |
response().out() << "Page not found"; |
} |
} |
|
Or you can use your own [template](/wikipp/en/page/cppcms_1x_templates): |
|
|
void myApplication::main(std::string url) { |
if (!dispatcher().dispatch(url)) { |
// Set the 404 status. |
response().status(http::response::not_found); |
content::main c; // Your main template. |
// c.content and c.title are defined in your template. |
c.content = "Use the search box."; |
c.title = "Page not found"; |
render("main", c); |
|
} |
} |
|
|
By default application::main() returns a 404 page if it does not find any dispatcher for a given url:
|
|
void application::main(std::string url) {
|
if(!dispatcher().dispatch(url)) {
|
response().make_error_response(http::response::not_found);
|
}
|
}
|
|
|
To create your own 404 page, you must override the default application::main().
|
|
void myApplication::main(std::string url) {
|
if (!dispatcher().dispatch(url)) {
|
// Set the 404 status.
|
response().status(http::response::not_found);
|
response().out() << "Page not found";
|
}
|
}
|
|
Or you can use your own [template](/wikipp/en/page/cppcms_1x_templates):
|
|
|
void myApplication::main(std::string url) {
|
if (!dispatcher().dispatch(url)) {
|
// Set the 404 status.
|
response().status(http::response::not_found);
|
content::main c; // Your main template.
|
// c.content and c.title are defined in your template.
|
c.content = "Use the search box.";
|
c.title = "Page not found";
|
render("main", c);
|
|
}
|
}
|
|
|
|