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 半导体 阅读(203) 评论(0)  编辑  收藏 所属分类: JAVA语法


只有注册用户登录后才能发表评论。


网站导航: