springmvc / ibeits / ajax

1. controller中的跳转可分为forward和redirect类型

("forward:/order/get_receipt_info.html");或

("redirect:/order/get_receipt_info.html");

2.controller中的跳转有几种方式

可以return url;

可以return modelAndView,如下:

modelAndView.addObject("customerId", customerId);
modelAndView.addObject("companyId",companyId);

modelAndView.setViewName("register");

return modelAndView;在页面用EL表达式${customerId}即可取出

3. ajax调用返回值时需要加@ResponseBody

4.list在页面循环出select

<select name="receipt" id="receipt" class="form-control ">
                  <c:forEach items="${receipts}" var="receipt">
<option value=${receipt.id} <c:if test='${receipt.isDefault == 1}'>selected="selected"</c:if>>
${receipt.receiptName}&nbsp;${receipt.contactNo}&nbsp;${receipt.address}</option>
</c:forEach>  
    </select> 

5. itetis如果配置了resultMap,如下:

  <resultMap id="customer" type="com.hj.custsys.wechat.entity.Customer" >
    <id column="cust_id" property="id" jdbcType="VARCHAR" />
    <result column="cust_name" property="name" jdbcType="VARCHAR" />
   
  </resultMap>
在sql语句中resultType="com.hj.custsys.wechat.entity.Customer" 或者用之前定义 的resultMap  resultMap="customer" 

6.页面ajax定义,可根据回调返回的值跳转到不同的请求

function register(){
console.log("register start...");
$.ajax({
  type:"post",
  dataType:"json",
  url:"save_customer.html",
  data:{
    phone:$("#phone").val(),
  },
  success:function(resp){
 console.log("method is::"+resp.method);
 if(resp.result==true){
 window.location.href = "get_receipt_info.html";
 }
 console.log("register end...");
  },
  error:function(resp){
  console.log("register error...");
  }
  });
}

7.定义dao接口的方法时,如果有多个参数需要加prameter注解

public List<ReceiptInfo> selectByCustomerId( @Param("companyId")  Integer  companyId,@Param("customerId")  String customerId); 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值