今天应该说没什么好讲的吧,感觉下面应该都是一样的套路了
贴两段较难的代码好了,虽然感觉还行
今天做了一个群组管理和一个数据字典,群组管理就直接可以复制粘贴的,但是数据字典有些地方是需要改的
数据字典的数据库截图:
页面效果简介:
点击进入数据字典时会按根目录进行查询,根目录的默认root为0
以数据字典中的车辆为例:
点击车辆后会通过root找到他下面的所有车辆信息
JSP页面中名称连接中搞一个root就行,就可以这样显示了
下面贴代码吧:
/**
* 列出所有的数据字典
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
private void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String root = "0";
if(request.getParameter("root")!=null){
root = request.getParameter("root");
}
DicService dicService = new DicService();
List<Dic> list = dicService.findDicByRoot(root);
request.setAttribute("dicList", list);
request.setAttribute("genmulu", root);
request.getRequestDispatcher("dic/dic.jsp").forward(request, response);
}
然后呢说一下新建吧:
新建界面如下:
通过"genmulu"获得以后给JSP中name为root的input标签然后跳转到新建页面的JSP中
输入名称和显示顺序后request中的方法取出来插入就行,之后再进行跳转
下面贴代码:
/**
* 添加新的数据字典
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
private void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String root = request.getParameter("genmulu");
request.setAttribute("root",root);
request.getRequestDispatcher("dic/dicAdd.jsp").forward(request, response);
}
/**
* 保存数据字典
* @param request
* @param response
* @throws IOException
* @throws ServletException
*/
private void save(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
DicService dicService = new DicService();
String dicname = request.getParameter("dicname");
int showorder = Integer.valueOf(request.getParameter("showorder"));
String root = request.getParameter("root");
String maxId = null;
if(root.equals("0")){//根目录添加直接加1就行
maxId = dicService.finMaxIdByRoot(root);
maxId = String.valueOf(Integer.valueOf(maxId)+1);
}else{
maxId = dicService.finMaxIdByRoot(root);
if(maxId==null){//如果根目录下还没有子数据字典那就把最大id设为root加上"0001"
maxId = root+"0001";
}else{//取出来加一,加一后不够4位在前面插0就行了
StringBuffer sub = new StringBuffer(String.valueOf(Integer.valueOf(maxId.substring(maxId.length()-4))+1));
while(sub.length()<4){
sub.insert(0, '0');
}
maxId = root+sub.toString();
}
}
Dic dic = new Dic(maxId, dicname, showorder, root);
dicService.addDic(dic);
this.list(request, response);
}
明天继续更新,室友一个接一个走了,明天貌似就2个人去了,emmmmm,可能太难_因为只有SE基础再加上JSP没有学过(虽然个人觉得还能接受的)????然后他们都选择了慵懒????/