JBOSS 點滴

          豐豐的博客

          啟動參數放MAP,轉換為對象,用戶編碼找到用戶名

          方法一:類轉換為map
          JAVA中編寫類CacheManager,方法如下:
              

           public void contextInitialized(javax.servlet.ServletContextEvent arg0) {
            WebInfoDBO webInfoDBO = (WebInfoDBO) SpringContext.getBean("WebInfoDBO");
            List list = webInfoDBO.queryBySql(" select detail_id as \"detailId\", genre_id as \"genreId\",type_two as \"typeTwo\", " + "title_name as \"titleName\",is_issue  as \"isIssue\",is_hot  as \"isHot\",content  as \"content\"" + "from   (select detail_id,genre_id,type_two, title_name, is_issue,is_hot,(select content from web_content c where web_info_d.detail_id=c.detail_id and is_hot='1') content,"
              + "rank() over(partition by genre_id order by sort_code,upt_date desc) rn      from web_info_d where is_issue='1') where rn<=1", WebInfoD.class);
            for (int i = 0; i < list.size(); i++) {
             WebInfoD webInfoD = (WebInfoD) list.get(i);
             tableComent.put("webInfoD", webInfoD);
            }

           }
          在JSP頁面獲取值方法:CacheManager:
          CacheManager cm = new CacheManager();
          WebInfoD webInfoD = (WebInfoD) cm.tableComent.get("webInfoD");
          out.println(webInfoD.getDetailId());
          out.println(cm.tableComent.get("detailId"));

          方法二:類轉換為map中KEY,VALUE
          JAVA中:

           public void contextInitialized(javax.servlet.ServletContextEvent arg0) {
            SysDictBO sysDictBO = (SysDictBO) SpringContext.getBean("SysDictBO");
            List list = sysDictBO.queryBySql(" select TYPE_DESC_ID as \"typeDescId\", TYPE_DESC_NAME as \"typeDescName\"  from  Sys_Dict_d d,sys_dict h where h.type_id=d.type_id", SysDictD.class);
            for (int i = 0; i < list.size(); i++) {
             SysDictD sysDictD = (SysDictD) list.get(i);
             tableComent.put(sysDictD.getTypeDescId(),sysDictD.getTypeDescName());
            }

           }

          JSP中:
          <%@ page import="com.gzlt.framework.cache.CacheManager" %>

          CacheManager cm = new CacheManager();
          WebInfoD webInfoD = (WebInfoD) cm.tableComent;

          out.println(cm.tableComent.get("402881c9405be55f01405c12f8240003"));


          posted on 2013-09-06 16:00 半導體 閱讀(231) 評論(0)  編輯  收藏 所屬分類: JAVA語法

          主站蜘蛛池模板: 龙岩市| 晴隆县| 盘山县| 武陟县| 武穴市| 界首市| 东丰县| 巧家县| 平度市| 饶平县| 水城县| 广平县| 泉州市| 句容市| 亳州市| 兴山县| 水城县| 修文县| 米脂县| 兰州市| 金乡县| 新邵县| 鹤壁市| 黄山市| 大邑县| 平舆县| 汽车| 汉中市| 孟州市| 舒兰市| 吴堡县| 象山县| 杂多县| 澄江县| 灵石县| 扶绥县| 咸宁市| 申扎县| 康马县| 阿勒泰市| 九龙县|