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語法

          主站蜘蛛池模板: 昌乐县| 老河口市| 兴隆县| 巴东县| 兴化市| 白水县| 阿城市| 蓬安县| 伊吾县| 嘉峪关市| 密山市| 龙井市| 永定县| 周宁县| 绥宁县| 淳安县| 阿鲁科尔沁旗| 婺源县| 河北省| 台东县| 常德市| 林口县| 大厂| 瑞安市| 庆城县| 莒南县| 博乐市| 驻马店市| 新竹市| 许昌市| 平昌县| 会泽县| 锡林郭勒盟| 荥经县| 玉溪市| 云安县| 县级市| 琼中| 子长县| 宜兰县| 永胜县|