图书管理系统(ssm框架)

1.前端 layui

2.spring springmvc mybatis mybatis逆向工程

项目目录

jsp引入路径

<link rel="stylesheet" href="../../layui/css/layui.css"  media="all">

<script src="../../layui/layui.js" charset="utf-8"></script>

表单问题

1.如果是表单提交方式传入后台数据日期类型需要在controller中转换

@InitBinder
	public void initBinder(WebDataBinder binder, WebRequest request) {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));// CustomDateEditor为自定义日期编辑器
	}

2.ajax提交方式以json数据格式方式提交

增加一个属性contentType : 'application/json;charset=UTF-8',

3.layui分页

当layui开启分页功能之后会自动向后台传递两个参数page limit 在controller要封装一个类一个为count的属性代表数据总条数

4.前端显示时间日期需要转化

<th lay-data="{field:'entryDate',width:100,
      templet: '#entryDate'}"
       width:120}">入职日期</th>
 <script type="text
  /html" id="entryDate">
{{# if(!(d.entryDate)){ }}
{{# }else{ }}
{{getLocalTime(d.entryDate)}}
{{# }}}
</script> 
<script>
function getLocalTime(nS) {
var time = new Date(nS);
var y = time.getFullYear();//年
var m = time.getMonth() + 1;//月
var d = time.getDate();//日
var h = time.getHours();//时
var mm = time.getMinutes();//分
var s = time.getSeconds();//秒
return (y+"-"+m+"-"+d)
}
</script>

5.角色传到前端为1 2 3需要显示为普通管理员超级管理员

 <th lay-data="{field:'roleId', width:80, fixed: 'right'
      
      ,templet:function(d){
      	let role = '未知';
      	if(d.roleId == 1){
      		role = '普通管理员';
      	}else if(d.roleId == 2){
      		role = '超级管理员';
      	}else if(d.roleId == 3){
      	   role='馆长'
      	}
      	return role;
      }
      
      }">角色</th>

猜你喜欢

转载自blog.csdn.net/hewenjing8168/article/details/81565918