`
uule
  • 浏览: 6307299 次
  • 性别: Icon_minigender_1
  • 来自: 一片神奇的土地
社区版块
存档分类
最新评论

返回值DataResponse

 
阅读更多

1、BaseResponse

public class BaseResponse
{
  protected boolean success = false;
  protected String msg;

  public boolean isSuccess()
  {
    return this.success;
  }
  public void setSuccess(boolean success) {
    this.success = success;
  }
  public String getMsg() {
    return this.msg;
  }
  public void setMsg(String msg) {
    this.msg = msg;
  }
}

 2、AddResponse

public class AddResponse extends BaseResponse
{
  private Object data;

  public Object getData()
  {
    return this.data;
  }

  public void setData(Object data) {
    this.data = data;
  }
}

 

3、DataResponse

public class DataResponse extends BaseResponse
{
  private Map<String, Object> data = new HashMap();

  public Map<String, Object> getData() {
    return this.data;
  }

  public void setData(Map<String, Object> data) {
    this.data = data;
  }
}

 

例子:

@RequestMapping(value = "/getLimitDetails", method = {RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public DataResponse getLimitDetails(Long id,Long parentId) {
	
		DataResponse response = new DataResponse();
		SmIaasQuotaV result = null;
		try {
			result = limitService.getLimitDetails(id,parentId);
			if(result != null){
				response.setData(BeanMapper.map(result, Map.class));
				response.setSuccess(true);
			}
		} catch(BusinessException e) {
			throw new ControllerException(HttpStatus.OK, e.getCode(), e.getMessage());
		} catch(Exception e) {
			final String msg = messageSource.getMessage(TipsConstants.QUERY_FAILURE);
			throw errorLogService.throwControllerException(LOGGER, HttpStatus.OK, null, msg, msg+",getLimitDetails error", e);
		}
		
		return response;
	}

 前台:

$.ajax({
		         url: _root + "/limit/getLimitDetails?id="+node.id+"&parentId="+node.parentId,
		         type: "GET", 
		         dataType: "json",
		         async:false,
		         success: function (data, textStatus, XMLHttpRequest) {
		        	  if(data.success){
		        		var model = data.data;
		        		 	
		      			$("#instanceLimits").val(model.instanceLimits);
		      			$("#publicIpLimits").val(model.publicIpLimits);
。。。
		        	  }
		        	 
		         }
		     });

 

。。

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics