zoukankan      html  css  js  c++  java
  • jersey中@QueryParam和@PathParam参数说明

    参考sdujava2011的博客,网址:http://blog.csdn.NET/sdujava2011/article/details/40053623


    @Path("/test")  
    public class RestTest1 {  
      
        @GET  
        @Path("/getMessage") 
        @Produces({ MediaType.APPLICATION_JSON })  
        public HashMap getClientedMessage(@QueryParam("from") int from, @QueryParam("to") int to) {  
            HashMap<String, String> map = new HashMap<String, String>();  
            map.put("abc", "def");  
            map.put("abc1", ""+from);  
            map.put("abc2", ""+to);  
            return map;  
        }  

    //请求方式为:    http://localhost:8080/resourceRest-1/api/test/getMessage?from=10&to=100

        @GET  
        @Path("{year}/{month}/{day}") 
        @Produces({ MediaType.APPLICATION_JSON })  
        public HashMap getClientedMessage2(@PathParam("year") int year,@PathParam("month") int month,   
                @PathParam("day") int day) { 
            HashMap<String, String> map = new HashMap<String, String>();  
            map.put("abc", "def");  
            map.put("abc1", ""+year);  
            map.put("abc2", ""+month);  
            map.put("abc3", ""+day);  
            return map;  
        }  

    //请求方式为:http://localhost:8080/resourceRest-1/api/test/2011/11/12

  • 相关阅读:
    转 Python学习(九)
    转 Python学习(八)
    转 Python学习(七)
    转 Python学习(六)
    转 Python学习(五)
    转 Python学习(四)
    转Python学习(三)
    转Python学习(一)
    面向对象第三章(向上造型、重写、重载)
    面向对象第一章(成员变量、局部变量、重载)
  • 原文地址:https://www.cnblogs.com/adjk/p/6427704.html
Copyright © 2011-2022 走看看