2019独角兽企业重金招聘Python工程师标准>>>
jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
%>
后台管理首页
banner
copyRight
代码
实体类
package com.laolang.gongda.easyuistudy.domain;
import javax.persistence.*;
@Entity
@Table(name = "sys_menu")
public class SysMenu {
@Id
@GeneratedValue
private Integer id;
@Column(unique = true)
private String text;
private String state;
@Column(name = "icon_cls")
private String iconCls;
private String url;
private Integer nid;
@Version
private Integer version;
}
数据库操作
- SysMenuRepository
package com.laolang.gongda.easyuistudy.repository;
import com.laolang.gongda.easyuistudy.domain.SysMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SysMenuRepository extends JpaRepository {
public List findByNid( Integer nId );
}
- SysMenuService
package com.laolang.gongda.easyuistudy.service;
import com.laolang.gongda.easyuistudy.domain.SysMenu;
import com.laolang.gongda.easyuistudy.repository.SysMenuRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class SysMenuService {
@Autowired
private SysMenuRepository sysMenuRepository;
@Transactional(readOnly = true)
public List findByNid( Integer nId ){
return sysMenuRepository.findByNid(nId);
}
}
controller
package com.laolang.gongda.easyuistudy.webadmin;
import com.laolang.gongda.easyuistudy.domain.SysMenu;
import com.laolang.gongda.easyuistudy.service.SysMenuService;
import com.laolang.gongda.easyuistudy.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@Controller
@RequestMapping(value="/admin/sysmenu")
public class SysMenuAdminController {
@Autowired
private SysMenuService sysMenuService;
@RequestMapping(value="list",method = RequestMethod.POST,produces = "text/html")
public String list( @RequestParam(value="id",required = false) Integer nId, HttpServletRequest request, HttpServletResponse response,Model model ) throws IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = response.getWriter();
String jsonStr = null;
Integer nid = nId == null ? 0 : nId;
List menus = sysMenuService.findByNid(nid);
jsonStr = JsonUtils.toJson(menus);
out.print(jsonStr);
out.flush();
out.close();
return null;
}
}
运行效果
关于 icon
来源
推荐一个icon图标的网站:
http://www.iconfont.cn/
这个网站提供了很多图标,且不用登陆,免费使用,提供多种尺寸,文档完整
easyui 添加 icon
从 iconfont 下载图标的时候要下载16X16的,然后修改名字,话到 jquery-easyui-1.4.5\themes\icons 中,再修改 jquery-easyui-1.4.5\themes\icon.css 文件,就可以使用了
/* mine */
.icon-home{
background:url('icons/home.png') no-repeat center center;
}
完整代码
http://git.oschina.net/laolang2016/easyui-study