我想知道如何从纯 html 文件中检索 POST 字段,而不使用从 cppcms::form 继承的类。我想要实现例如这个类的类:
std::string Index::main(const std::string &url, const std::map<std::string, std::string> parameters)
{
std::string out = (
"<html>\n"
"<body>\n"
"<form name='test' action='' method='post'>"
"<h1>Hello, put your name here:</h1><br />"
"<input type='text' name='user'>"
"<input type='submit' value='Submit'>"
"</form>"
"</body>\n"
"</html>\n"
);
return out;
}
此方法在继承自 cppcms::application 的类中调用:
void Engine::main(const std::string &url)
{
std::map<std::string, std::string> params;
pages["/"] = boost::bind(&Index::main, boost::shared_ptr<Index>(new Index), _1, _2);
std::string out = pages[url](url, params); // Call to Index::main
response().out() << out;
}
我想做的是检索“user”字段并将其放入“params”映射中,而不必让我的 Index 类继承自 cppcms::form 或使用“post”中的“get”方法。我希望 html 文件/类完全独立于 cppcms 框架。可能吗?谢谢你。