码迷,mamicode.com
首页 > 编程语言 > 详细

Spring MVC取变量值

时间:2015-06-04 19:16:46      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

@RequestMapping(value = "/dflights/cityLowPrice", method = { RequestMethod.GET }, headers = "Accept=application/json")
 public CommResponse searchCityLowPrice(
   @RequestParam(value = "depCity", required = true) String depCity,
   @RequestParam(value = "qDays", defaultValue = "30") int qDays,
   @RequestParam(value = "qLines", defaultValue = "10") int qLines,
   @RequestParam(value = "daysPerLine", defaultValue = "1") int daysPerLine) {

  CommResponse ret;

  List<LowPriceContent> list;
  try {
   this.verify(depCity, qDays, qLines, daysPerLine);

   list = lowPriceService.getCityLowPrice(depCity, qDays, qLines,
     daysPerLine);
   List<LowPriceODT> lowPrices = new ArrayList<LowPriceODT>();

   for (LowPriceContent lowPriceContent : list) {
    LowPriceODT odt = new LowPriceODT();

    odt.setCfcsdm(lowPriceContent.getDepartCity());
    String searchItem = baseInfoService
      .getAviationCityNameByCode(lowPriceContent
        .getDepartCity());
    if (searchItem != null) {
     odt.setCfcs(searchItem);
    }

    odt.setDdcsdm(lowPriceContent.getArrivelCity());
    searchItem = baseInfoService
      .getAviationCityNameByCode(lowPriceContent
        .getArrivelCity());
    if (searchItem != null) {
     odt.setDdcs(searchItem);
    }

    odt.setCfrq(lowPriceContent.getDate());
    odt.setGj(CurrencyUtil.convertFen2YuanText(lowPriceContent
      .getPrice()));
    odt.setZk(lowPriceContent.getDiscountRate());
    lowPrices.add(odt);
   }
   CommResponseWithArray<LowPriceODT> response = new CommResponseWithArray<LowPriceODT>();
   response.setIsSuccess("Y");
   response.setFailReason("");
   response.setData(lowPrices);
   ret = response;

  } catch (ServiceException e) {
   ret = new CommResponse();
   ret.setIsSuccess("N");
   ret.setFailReason(e.getMsg());
  }
  return ret;
 }

 

Spring MVC取变量值

标签:

原文地址:http://www.cnblogs.com/duojia/p/4552441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!