button按钮提交表单信息

//表单
<form action="/showUser" method="get" id="select">
<span>用户名:</span>
<input type="text" name="name" placeholder="请输入用户名"/>
<input type="button" onclick="submitForm()" value="查询"/>
<a href="userAdd.html">添加用户</a>
</form>


//js代码
<script>
function submitForm(){
//获取form表单对象,提交选择项目
var form = document.getElementById("select");
form.submit();//form表单提交
}
</script>

//service层代码
public PageInfo<SmbmsUser> showUser(int pageNum,String name){
//当前页 页面容量
PageHelper.startPage(pageNum,5);

Example example = new Example(SmbmsUser.class);
Example.Criteria criteria = example.createCriteria();

if (!StringUtils.isEmpty(name)){
//通过用户名模糊查询
criteria.andLike("username",'%' + name + '%');
}

List<SmbmsUser> smbmsUsers = smbmsUserMapper.selectByExample(example);
bindUser(smbmsUsers);
PageInfo<SmbmsUser> pageInfo = new PageInfo<>(smbmsUsers);
return pageInfo;
}
上一篇:Linux_shell_整数二元比较操作符


下一篇:Leetcode 1647. 字符频次唯一的最小删除次数(DAY 126) ---- 贪心算法学习期