Wt C ++-将GET值添加到URL

Pan*_*Jan 5 c++ get wt

我是否可以在witty库中的URL中添加GET值,例如:www.somewebsite.com?SomeSuperValue=12&other=something?

Ped*_*ira 2

我从未尝试过,但我认为这可能会做到:

#include <Wt/WEnvironment>

const WEnvironment& env = WApplication::instance()->environment();
   ...
 // read an application startup argument 
 // (passed as argument in the URL or POST'ed to the application).
 if (!env.getParameterValues("login").empty())
 {
   std::string login = env.getParameterValues("login")[0];
 }
Run Code Online (Sandbox Code Playgroud)

如果您使用 c++,您还可以将 WEnvironment& env 作为 WApplication 类重载的参数。

编辑:我刚刚测试了它并且它有效!