java 代码优化
@RequestMapping("admin/teacherList.do")
public ModelAndView teacherList(HttpSession session, String type) {
String teacher_dept_id = (String) session
.getAttribute("teacher_dept_id");
// 当前下拉框选中的值,不是当前老师的所在部门
if (type != null) { // type 为标记,如果不为空,表示之前已经选择过院系,再次进入页面应该清空,重新选择下拉框
session.removeAttribute("teacher_dept_id");
teacher_dept_id = null;
}
;
Map<String, Object> map = new HashMap<String, Object>();
String college_id = (String) session.getAttribute("college_id");// 得到负责的学院
// 得到该院所有的系和学院本身
List<Org> collegeAndDepts = this.orgService
.selectByXueYuanId(college_id);
// 获取学院教师列表
List<Teacher> teaList = this.teacherService
.selectListByXuId(college_id);
// 分页
int pageSize = 15;
int Currentpage = 1;// 初始值1
/*
if(teaList.size()<pageSizeConstant){//防止集合大小不满足每页记录,进行赋值。
pageSize=teaList.size(); }
*/
// 获取当前页集合
List<Teacher> listCurrentPage = Common.getListCurrentPage(teaList,
pageSize, Currentpage);
// 得到总页数
pageCount = Common.getPageCount(teaList, pageSize, Currentpage);
// 放到session,方便分页时调用
session.setAttribute("xinxi", teaList);
map.put("count", pageCount);
map.put("result", listCurrentPage);
map.put("nowPage", Currentpage);
map.put("xi", collegeAndDepts);// 下拉框
map.put("teacher_dept_id", teacher_dept_id);
new ModelAndView("admin/teacherList", map);
}
伊谢尔伦2017-04-17 17:41:31
What to optimize?
Where is the bottleneck?
I hope the problem description is clearer