Layui 后台加载菜单栏名称以及url

一个小小的demo,演示从Controller层传参到视图,有使用到SpringMvc、jstl标签

效果图:

Layui 后台加载菜单栏名称以及url_第1张图片

1、testdemo.jsp

<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8" pageEncoding="utf-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>




Insert title here



	



	

	
	

2、TestController.java

@Controller
@Scope(value = "prototype")
@RequestMapping("/")
public class TestController {
	@RequestMapping(value="/testdemo") //从上一个页面跳转过来,如果只是看看效果直接输入http://localhost:8080/项目名/testdemo
	public  String  Test(Model model)
	{
		List>list1=new ArrayList();
		List l1 = Arrays.asList("二级菜单1","二级菜单2","二级菜单3");//模拟获得数据
		List l2 = Arrays.asList("/url1","/url2","/url3");
		List>list2=new ArrayList();
		List l3 = Arrays.asList("三级菜单1","三级菜单2","三级菜单3","三级菜单4");//模拟获得数据
		List l4 = Arrays.asList("/url1","/url2","/url3","/url4");
		list1.add(l1);
		list1.add(l2);
		list2.add(l3);
		list2.add(l4);
		model.addAttribute("itemname1",list1);
		model.addAttribute("itemname2",list2);
		return"testdemo";
		}
}

你可能感兴趣的:(Layui 后台加载菜单栏名称以及url)