你不想要 json 串形式的返回?

解决方案 »

  1.   

    callbackApi.valid()你这个返回是啥?
      

  2.   


    是个字符串,关键是它在页面上看到的是方法参数的json,而不是方法返回值的JSOn
      

  3.   


    是的,我是想要方法返回值的JSON
      

  4.   

    加上这个@RequestMapping("/index"),他会跳转到return指定的视图,你可以再该视图里附加json数据。具体请学习modelAndView
      

  5.   

    String 对象是要返回视图用。返回 json 串你可以这样:
    /** 
         * 测试返回JSON数据 
         * @param session 
         * @return 
         */  
        @RequestMapping(value="/test")  
        @ResponseBody  
        public Object test(HttpSession session){  
              
            System.out.println("test....................");  
            return session.getAttribute("permit");  
        }  
      

  6.   


    http://localhost:8090/YueHuiBarWechat/api/index.json?signature=wexin&timestamp=123&nonce=321&echostr=456加上@ResponseBody    json正常,但是XML就报错了http://localhost:8090/YueHuiBarWechat/api/index.xml?signature=wexin&timestamp=123&nonce=321&echostr=456This page contains the following errors:error on line 1 at column 1: Document is empty
    Below is a rendering of the page up to the first error.
      

  7.   

    @RequestMapping("/index")
    @ResponseBody
    public String index(WechatCallbackAPI callbackApi) {
    String validStr = callbackApi.valid();
    return validStr;
    // map.addAttribute("vv", validStr);
    }
      

  8.   

    你什么意思呢?
    到底是想返回 json,还是 html 页面
      

  9.   

    返回json但json是方法参数的json,不是方法返回值的参数。
      

  10.   

    首先要返回huo首先你确定你这个犯法返回的是个json值,而且确定你前台接受的也是json值