0
点赞
收藏
分享

微信扫一扫

Spring mvc 返回JSON

public ModelAndView updateContractTitle (HttpServletRequest request,
    HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView();
        long applyId = Long.valueOf(request.getParameter("applyId"));
        AbstractApply apply = applyDao.getApplyById(applyId);
        apply.setApplyTitle(request.getParameter("contractTitle"));
        for(Object t : apply.getApplyTarget()){
            AbstractApplyTarget c = (AbstractApplyTarget) t;
            c.setTitle(apply.getApplyTitle());
        }
        applyDao.merge(apply);//以上是业务逻辑        //开始返回
        MappingJacksonJsonView view = new MappingJacksonJsonView();
        Map attributes = new HashMap();
        attributes.put("success", Boolean.TRUE); attributes.put("contractNo", "contractNo");
        view.setAttributesMap(attributes);
        mav.setView(view);
        return mav;
    } 
 
 

   
 
 
 

   
 
 
 

   var URL = "approve.do?action=approveC"
  
 
  

               $.ajax({
  
 
  

                   type:"POST",
  
 
  

                   url:URL,
  
 
  

                   data:null,
  
 
  

                   success:function(msg){
  
 
  
contractNo
   ”值
 
  

                   },
  
 
  

                   error:function(msg){
  
 
  

                   }
  
 
  

               });

举报

相关推荐

0 条评论