当前位置: 首页>>代码示例>>C++>>正文


C++ HttpServletRequest::getParameterNames方法代码示例

本文整理汇总了C++中HttpServletRequest::getParameterNames方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpServletRequest::getParameterNames方法的具体用法?C++ HttpServletRequest::getParameterNames怎么用?C++ HttpServletRequest::getParameterNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest::getParameterNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doGet

void FormTestServlet::doGet(HttpServletRequest& req, HttpServletResponse& resp)
{
	ServletOutputStream& ostr = resp.getOutputStream();

	ostr <<
		"<html>\n"
		"<head>\n"
		"<title>POCO Form Server Sample</title>\n"
		"</head>\n"
		"<body>\n"
		"<h1>POCO Form Server Sample</h1>\n"
		"<h2>GET Form</h2>\n"
		"<form method=\"GET\" action=\"/ServletTest/FormTestServlet\">\n"
		"<input type=\"text\" name=\"text\" size=\"31\">\n"
		"<input type=\"submit\" value=\"GET\">\n"
		"</form>\n"
		"<h2>POST Form</h2>\n"
		"<form method=\"POST\" action=\"/ServletTest/FormTestServlet\">\n"
		"<input type=\"text\" name=\"text\" size=\"31\">\n"
		"<input type=\"submit\" value=\"POST\">\n"
		"</form>\n";
		
	ostr << "<h2>Request</h2><p>\n";
	ostr << "Method: " << req.getMethod() << "<br>\n";
	ostr << "URI: " << req.getRequestURI() << "<br>\n";
	
	std::vector<std::string> names = req.getParameterNames();
	std::vector<std::string>::iterator it = names.begin();
	for(; it != names.end(); ++it)
		ostr << *it << ":" << req.getParameter(*it);

	ostr << "</p>";

	ostr << "</body>\n";
}
开发者ID:RangelReale,项目名称:sandbox,代码行数:35,代码来源:TestServlet.cpp

示例2: make_naviLink

string Products::make_naviLink(HttpServletRequest& request) {
    auto_ptr< vector<string> > names_ptr = request.getParameterNames();
    vector<string>& names = *names_ptr;
    string link;
    for(unsigned i=0;i<names.size(); ++i) {
        if(names[i] == "productsPage")
            continue;
        link += link.empty()?'?':'&';
        link += names[i] + "=" + request.getParameter(names[i]);
    }
    link += (link.empty()?'?':'&') + string("productsPage=");
    return ("Products.sxx"+link);

}
开发者ID:rzymek,项目名称:cxxsp,代码行数:14,代码来源:Products.cpp

示例3: doGet

    void doGet(HttpServletRequest& req, HttpServletResponse &res) {
        //dbg_stop();

        res.setContentType("text/html");
        ostream& out = res.getOutputStream();
        out << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""
            "\"http://www.w3.org/TR/html4/loose.dtd\">" << endl;
        out << "<html><head><title>test</title></head><body>" << endl;
        out << "PID: " << getpid() << "<hr>" << endl;

        auto_ptr< vector<string> > names = req.getHeaderNames();

        out << "<div style='border: solid black'>" << endl;
        out << "Headers:<ul>" << endl;
        for(unsigned i=0; i< names->size();++i) {
            out << "<li>" << (*names)[i] << "<ul>";
            auto_ptr< vector<string> > values = req.getHeaders((*names)[i]);
            for(unsigned j=0; j < values->size();++j) {
                out << "<li>" << (*values)[j] << "</li>";
            }
            out << "</ul>\n";
        }
        out << "</ul></div><br>\n";

        out << "<div style='border: solid black'>" << endl;
        out << "Cookies:<ul>" << endl;
        auto_ptr< vector<Cookie> > cookies = req.getCookies();
        for(unsigned i=0;i<cookies->size();++i)
            out << "<li><u>" <<  (*cookies)[i].getName() << "</u> "
                << (*cookies)[i].getValue() << "</li>\n" << endl;
        out << "</ul></div><br>\n";


        out << "<div style='border: solid black'>" << endl;
        out << "Parameters:<ul>" << endl;
        names = req.getParameterNames();
        for(unsigned i=0; i< names->size();++i) {
            out << "<li>" << (*names)[i] << "<ul>";
            auto_ptr< vector<string> > values = req.getParameterValues((*names)[i]);
            for(unsigned j=0; j < values->size();++j) {
                out << "<li>" << (*values)[j] << "</li>\n";
             //   Cookie c(names[i], req.getParameter(names[i]));
             //   res.addCookie(c);
            }
            out << "</ul>\n";
        }
        out << "</ul></div><br>";

        HttpSession* session = req.getSession();
        if(session){
            int cnt;
            if(session->isNew()){
                cnt = 1;
                session->setAttribute("cnt",cnt);
            }else{
                cnt = session->getAttribute<int>("cnt");
                cnt++;
                session->setAttribute("cnt",cnt);
            }
            out << "Your counter: " << cnt << endl;
            out << "<br>ID: " << session->getId() << endl;
        }else
            out << "<h4>No session</h4>";

        out << "</body></html>" << endl;
    }
开发者ID:rzymek,项目名称:cxxsp,代码行数:66,代码来源:test.cpp


注:本文中的HttpServletRequest::getParameterNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。