- 重置表单
function reset_form(ele){
$(ele)[0].reset();
$(ele).find("*").removeClass("has-error has-success");
$(ele).find(".help-block").text("");
}
- 后端controller层进行数据校验
String regx = "^[a-z0-9_-]{3,16}$";
if (!empName.matches(regx)){
return Msg.fail().add("va_msg","用户名必须是6-16为数字和字母组成-controller层");
}
- 获取表单中的数据
data:$("#empAddmodal form").serialize(),
- 获取地址中的id 。 @PathVariable(“id”)Integer id
@RequestMapping(value = "/emp/{id}",method = RequestMethod.GET)
@ResponseBody
public Msg getEmp(@PathVariable("id")Integer id){
Employee employee = employeeService.getEmp(id);
return null;
}
- jquer如何设置input、radio、select的值
success:function (reuslt){
var empData = reuslt.extendData.emp;
$("#empName_update_static").text(empData.empName);
$("#email_update_input").val(empData.email);
$("#empUpdateModal input[name=gender]").val([empData.gender]);
$("#empUpdateModal select").val([empData.dID]);
}
- 浏览器如何弹出提示框
if (confirm("确认删除【"+empName+"】吗?")){}
- 字符串专为int类型
if (ids.contains("-")){
List<Integer> del_ids = new ArrayList<>();
String[] str_ids = ids.split("-");
for (String string : str_ids) {
del_ids.add(Integer.parseInt(string));
}
employeeService.deleteBatch(del_ids);
}