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} ${receipt.contactNo} ${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);