<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
href="css/shopbs/catalogDesign.css">
这是前台遍历与添加菜单的代码
/**
* 跳转目录设计
*/
@RequestMapping(value = "/tocatalogDesign")
public ModelAndView tocatalogDesign(HttpServletRequest request) {
Map<String, Object> result = new HashMap<String, Object>();
Shop shop = (Shop)request.getSession().getAttribute("shop");
List<Shopmenu>shopmenulist = shopmenuService.queryBySqlQuery("from Shopmenu sm where sm.parentId is null and sm.type=0 and sm.shop.id=?", new Object[]{shop.getId()});
result.put("shopmenulist", shopmenulist);
return new ModelAndView("shopbs/order/catalogDesign",result);
}
/**
* 目录设计 一级菜单
*/
@RequestMapping(value="/addcatalogDesign",method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> addcatalogDesign (HttpServletRequest request,Shopmenu shopmenu){
System.out.println("进入非法");
Map<String, Object>result = new HashMap<String,Object>();
Shop shop = (Shop)request.getSession().getAttribute("shop");
String warnInfo = "";
int status = 0;
if(Common.isNull(shopmenu.getParentId())){
shopmenu.setShop(shop);
shopmenu.setType(0);
shopmenuService.save(shopmenu);
warnInfo = "添加一级菜单成功";
status = 1;
}
result.put("warnInfo", warnInfo);
result.put("status", status);
return result;
}
/**
* 目录设计 二级菜单
*/
@RequestMapping(value="/addsubshopmenu",method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> addsubshopmenu(HttpServletRequest request,Shopmenu shopmenu){
System.out.println("进入合法");
Map<String, Object>result = new HashMap<String,Object>();
Shop shop = (Shop)request.getSession().getAttribute("shop");
String warnInfo = "";
int status = 0;
if(!Common.isNull(shopmenu.getParentId())){
shopmenu.setShop(shop);
shopmenu.setType(0);
shopmenuService.save(shopmenu);
warnInfo = "添加二级菜单成功";
status = 1;
}else{
warnInfo = "非法操作";
}
result.put("warnInfo", warnInfo);
result.put("status", status);
return result;
}
这是后台查询及添加菜单代码