请教个python httplib2传递参数问题

youngjdong 发布于 2013/07/24 14:30
阅读 841
收藏 0
参考网上例子:
def call_bh(url):
    try:
        http = Http()

        #post
        # data = dict(querys="user")
        data = {'querys':'user'}
        headers = {'Content-type':'text/xml;charset=UTF-8'}
        response,content = http.request(url, "POST",body=urlencode(data), headers = headers, )

        print content
    except Exception, e:
        print e
        print 'fail to call back hawk'
    else:
        print 'success to call back hawk'
服务端采用springside,
@RequestMapping("/chart_xml2")
    public @ResponseBody
    Map<String, Object> getChartDataXml2(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> re = new HashMap<String, Object>();

        String q = request.getParameter("querys");
        logger.debug("" + q);

        String s = "<graph xaxisname='月度' yaxisname='销售' subcaption='机构本季度销售统计'><set name='1月' value='10' color='D2626' /><set name='2月' value='10' color='D64646' /><set name='3月' value='11' color='AFD8F8' /></graph>";
        s = q;
        re.put("success", true);
        re.put("xmldata", s);

        return re;
}
总是得不到参数
加载中
0
SupNatural
SupNatural
每种服务器的request对象都有所区别,先把整个request打印出来看看。还有RequestMapping("/chart_xml2")这个装饰器不知道干嘛的,也许修改了request。
youngjdong
youngjdong
浏览器直接访问http://localhost:8090/sshapp/common/chart_xml2正常
0
pager
pager
headers = {'Content-type':'application/x-www-form-urlencoded'}
pager
pager
替换这个headers
返回顶部
顶部