ExtJS3 简单主页面 构

阅读更多

一. 页面JSP代码如下

 

<%
 String userName =  (String)request.getAttribute("username");
 %>







<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String basepath=request.getContextPath();%>

  
	
	1
	
	  
	  
	
	
	
	  		
	
	
	
	
	
	
	
	
	  	




 
  

 

2.menu 数据加载

 

struts 配置如下:

 


  
  

 

 

java代码如下:

1.action

    public String queryMenuList() throws Exception
    {
        Map params_new = exchangeParams();
        String str = menuManageService.queryMenuList(params_new);
      
             String encding = "UTF-8";
		response.setContentType(CONTENT_TYPE);
		OutputStream out = response.getOutputStream();
		out.write(str.getBytes(encding));
		out.flush();
		out.close()

return NONE; }

 
  

 

 

2.service

public String queryMenuList(Map params) throws Exception
    {
        String menuStr = "";
        List list = null;
        if (null != params && !params.isEmpty())
        {
            list = menuManageDAO.queryMenuList(params);
        }
         return JSONArray.fromObject(list).toString();;
    }

 

3.dao

  public List queryMenuList(Map params)
    {
        List argsList = new ArrayList();
        StringBuffer sql = new StringBuffer();
        Object args[] = null;
        int argTypes[] = null;
       
        sql.append("SELECT DISTINCT M.MENU_ID ID,NAME TEXT,(CASE M.MENU_FOLDER_FLAG  WHEN '2' THEN 'TRUE' ELSE 'FALSE' END  ) LEAFTEMP,SORT_NO,HANDLE_REPRESENT ");
        sql.append(" FROM " + this.tableSchema).append(".F_CONFIG_MENU M  WHERE 1=1 ");
        
        String userName = String.valueOf(params.get("username"));
        List menuList = null;
        if (!StringUtil.isEmpty(userName))
        {
            menuList = userDao.queryMenuListByUserName(userName);
        }
        
        String ss = "'";
        for (int i = 0; i < menuList.size(); i++)
        {
            Map m = (Map)menuList.get(i);
            String str = String.valueOf(m.get("MENUID"));
            if (!StringUtil.isEmpty(str))
                ss += str + "','";
        }
        ss = ss.substring(0, ss.length() - 2);
        if (ss != "")
        {
            sql.append(" and M.MENU_ID in (").append(ss).append(") ");
        }
        
        if (StringUtil.isNullOrEmpty(params.get("p_menu_code")))
        {
            sql.append("AND (P_MENU_CODE=(SELECT MENU_ID FROM " + this.tableSchema);
            sql.append(".F_CONFIG_MENU WHERE P_MENU_CODE IS NULL)) ");
        }
        else
        {
            sql.append("AND P_MENU_CODE=? ");
            argsList.add(params.get("p_menu_code"));
        }
     
        sql.append("order by sort_no ");
      
        if (argsList.size() > 0)
        {
            args = new Object[argsList.size()];
            argTypes = new int[argsList.size()];
            for (int i = 0; i < argsList.size(); i++)
            {
                args[i] = (Object)argsList.get(i);
                argTypes[i] = Types.BIGINT;
            }
        }
       
        return jdbcTemplateEx.query(sql.toString(), args, argTypes, new SuyRowMapper(MenuBean.class));
    }
 public List queryMenuListByUserName(String userName)
    {
        StringBuffer sb = new StringBuffer();
        sb.append(" select m.menu_id menuid,U.* from ")
            .append(this.tableSchema)
            .append(".")
            .append("sys_role_menu_ref m, ")
            .append(this.tableSchema)
            .append(".")
            .append("F_config_user u where m.role_id = u.roleid ")
            .append(" and u.name= ?");
       
        return this.jdbcTemplateEx.queryForList(sb.toString(), new Object[] {userName}, new int[] {Types.VARCHAR});
    }

 

	   



 

简单表结构如下:

 

create table SYS_MENU  (
   MENU_ID              NUMBER(16)                      not null,
   NAME                 VARCHAR2(256),
   TITLE                VARCHAR2(256),
   P_MENU_CODE          VARCHAR2(16),
   MENU_FOLDER_FLAG     VARCHAR2(8),
   HANDLE_REPRESENT     VARCHAR2(256),
  
   --PK_SYS_MENU_ID primary key (MENU_ID)
)
create table SYS_ROLE_Menu_REF  (
  ROLE_Menu_REF_ID  NUMBER(16)                      not null,
  Menu_ID           NUMBER(16)                      not null,
   ROLE_ID              NUMBER(16)                      not null,
   ---SYS_ACCOUNT_ROLE_REF_PK primary key (ACCOUNT_ROLE_REF_ID)
)

 

 

你可能感兴趣的:(html,框架,extjs)