Отличия "Модификация страницы 404" вер. 1 сравн. вер. 2
		
	
	
		Содержимое:
		
	
	
	
		| По-умолчанию application::main() возвращает страницу 404, если не находит какой-либо иной путь для данного URL: | 
	
	
		|  | 
	
	
		|     void application::main(std::string url) { | 
	
	
		|        if(!dispatcher().dispatch(url)) { | 
	
	
		|            response().make_error_response(http::response::not_found); | 
	
	
		|        } | 
	
	
		|     } | 
	
	
		|  | 
	
	
		|  | 
	
	
		| Для создания собственной страницы 404, необходимо переопределить стандартный 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"; | 
	
	
		|       } | 
	
	
		|     } | 
	
	
		|  | 
	
	
		| Или воспользоваться своим собственным [шаблоном](/wikipp/en/page/cppcms_1x_templates): | 
	
	
		| Или воспользоваться своим собственным [темплейтом](/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); | 
	
	
		|  | 
	
	
		|       } | 
	
	
		|     } | 
	
	
		|  | 
	
	
		|  | 
	
	
	
	
	
	 
	
		
Проект
CppCMS является основой веб-разработки для выполнения ресурсоемких приложений.
Размещение

 
 

Навигация
Главная страница
		
		
		Валидация CSS 
		| Валидация XHTML 1.0