Jquery异步提交表单(post)
方法 $.post(url,params,function(data){});
创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、成都网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的汉阳网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
表单的action,method属性都没有
input 的类型只能为button不能为submit只能为button,否则点击button会执行表单action,不会走jquery异步
前台代码
后台代码:
public void save(){ PrintWriter out=null; try { System.out.println(oid); System.out.println(remark); orderService.saveRemark(oid,remark); HttpServletResponse response=ServletActionContext.getResponse(); out=response.getWriter(); out.print(true); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); out.flush(); out.close(); out.println(0); } }
webx框架
velocity模板实现代码
分页bean
package com.alibaba.uyuni.biz.common.bo.dto; import java.io.Serializable; import com.alibaba.uyuni.common.enums.NumEnum; /** * 类Page.java的实现描述:TODO 类实现描述 * * @author 杨冬 2014年8月21日 下午1:19:25 */ public class UyuniPageimplements Serializable { /** * */ private static final long serialVersionUID = 8104777827863916550L; /** 每页显示记录数 **/ private Integer pageSize; /** 查询的集合 **/ private T data; /** 总页数 **/ private int totalPage; /** 当前页,第几页 **/ private Integer pageIndex; /** 总记录数 **/ private Integer totalNum; /** 是否有下页 **/ private boolean hasNextPage = false; /** 是否有上页 **/ private boolean hasPreviousPage = false; /** * @param pageSize 每页条数 * @param pageIndex 当前页,第几页 * @param totalNum 总记录数 * @param data 查询的集合 */ public UyuniPage(Integer pageSize, Integer pageIndex, Integer totalNum, T data){ super(); if (pageSize == null || pageSize == 0) { pageSize = NumEnum.FIVE.getValue(); } if (pageIndex == null || pageIndex == 0) { pageIndex = NumEnum.ONE.getValue(); } if (totalNum == null || totalNum == 0) { totalNum = 0; } this.pageSize = pageSize; this.data = data; // pageSize==0会报错 this.totalPage = (totalNum % pageSize == 0) ? (totalNum / pageSize) : (totalNum / pageSize + 1); this.pageIndex = (pageIndex == 0) ? (1) : (pageIndex); this.totalNum = totalNum; this.hasNextPage = (this.totalPage > 1 && this.totalPage > this.pageIndex); this.hasPreviousPage = (this.pageIndex > 1); } /** * @return the pageSize */ public Integer getPageSize() { return pageSize; } /** * @param pageSize the pageSize to set */ public void setPageSize(Integer pageSize) { this.pageSize = pageSize; } /** * @return the data */ public T getData() { return data; } /** * @param data the data to set */ public void setData(T data) { this.data = data; } /** * @return the totalPage */ public int getTotalPage() { return totalPage; } /** * @param totalPage the totalPage to set */ public void setTotalPage(int totalPage) { this.totalPage = totalPage; } /** * @return the pageIndex */ public Integer getPageIndex() { return pageIndex; } /** * @param pageIndex the pageIndex to set */ public void setPageIndex(Integer pageIndex) { this.pageIndex = pageIndex; } /** * @return the totalNum */ public Integer getTotalNum() { return totalNum; } /** * @param totalNum the totalNum to set */ public void setTotalNum(Integer totalNum) { this.totalNum = totalNum; } /** * @return the hasNextPage */ public boolean isHasNextPage() { return hasNextPage; } /** * @param hasNextPage the hasNextPage to set */ public void setHasNextPage(boolean hasNextPage) { this.hasNextPage = hasNextPage; } /** * @return the hasPreviousPage */ public boolean isHasPreviousPage() { return hasPreviousPage; } /** * @param hasPreviousPage the hasPreviousPage to set */ public void setHasPreviousPage(boolean hasPreviousPage) { this.hasPreviousPage = hasPreviousPage; } /** * @return the serialversionuid */ public static long getSerialversionuid() { return serialVersionUID; } }
vm页面
buttom标签必须放到form标签外面,否则点击button会执行表单action,不会走绑定的异步事件
分页显示页面
#set($nextpage=$pb.pageIndex + 1) #set($previouspage=$pb.pageIndex - 1) #if($pb.hasPreviousPage == true) 上一页 #end #if($pb.hasNextPage == true) 下一页 #end
#foreach(${studentDto} in ${result}) ${studentDto.id} ${studentDto.name} ${studentDto.age} ${studentDto.sex} ${studentDto.grade} ${studentDto.team} ${studentDto.teacher} 编辑 删除
#end 新增
vm做加减运算必须在set标签里面做,且运算符两边必须有空格
#set($a=10)
#set($b=$a - 1)
------------
$b
不能直接像freemaker一样 ${b-1}
http://liu400liu.iteye.com/blog/1197466
参考文章:
http://1194867672-qq-com.iteye.com/blog/1945827
网站栏目:Jquery异步提交表单(post)
标题网址:http://scyanting.com/article/ggspeg.html