ssm框架 返回 json格式数据

来源:互联网 发布:mac视频拷贝到u盘 编辑:程序博客网 时间:2024/06/01 10:09

1. maven导入json jar包

 <dependency>  
            <groupId>org.codehaus.jackson</groupId>  
            <artifactId>jackson-mapper-asl</artifactId>  
            <version>1.9.13</version>  
        </dependency> 

2.在Spring-mvc.xml中配置<mvc:annotation-driven></mvc:annotation-driven>

3.Controller中使用@ResponseBody注解

 @RequestMapping(value = "/showOrderNo", method = RequestMethod.POST)  
    public @ResponseBody PaymaxRefundResult post(@RequestParam(required=false) String name, @RequestParam ( "id" ) int id){    
        PaymaxRefundResult pay = this.payService.getPaymaxRefundResultById(id); 
        return pay;  
    }  

原创粉丝点击