loginAction中对Application的应用

日志 >  个人日记
发表于:2008年2月23日 9时38分54秒阅读(3)评论(0)特效:[信纸] 本文链接:http://user.qzone.qq.com/592433424/blog/1203730734
loginAction中对Application的应用
package com.shzscq.searchpatent.web.action;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.Globals;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import com.shzscq.searchpatent.hibernate.domain.DbinfoDAO;
import com.shzscq.searchpatent.hibernate.domain.RoleinfoDAO;
import com.shzscq.searchpatent.hibernate.domain.Userinfo;
import com.shzscq.searchpatent.hibernate.domain.UserinfoDAO;
import com.shzscq.searchpatent.web.form.LoginForm;
/**
* MyEclipse Struts Creation date: 01-23-2008
*
* XDoclet definition:
*
* @struts.action path="/login" name="loginForm" input="/form/login.jsp"
*                parameter="ok" scope="request"
* @struts.action-forward name="ok" path="/index.jsp"
*/
public class LoginAction extends Action {
/*
  * Generated Methods
  */
/**
  * Method execute
  *
  * @param mapping
  * @param form
  * @param request
  * @param response
  * @return ActionForward
  */
public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response) {
  // LoginForm lf = (LoginForm)form;
  LoginForm lf = (LoginForm) form;
  if(lf.getUserId()==null| lf.getPassword()==null){
    return new ActionForward(mapping.getInput());
  }
  ActionMessages errors=new ActionMessages();
  HttpSession session = request.getSession();
  session.setAttribute("errid", errors);
  String userid = lf.getUserId();
  String pwd = lf.getPassword();
  Userinfo user = null;
  UserinfoDAO dao = new UserinfoDAO();
  RoleinfoDAO roleinfoDAO = new RoleinfoDAO();
  user = dao.findById(userid);
  DbinfoDAO dbinfoDAO = new DbinfoDAO();
  if (user != null && user.getUserId() != null
    && user.getPassword().equals(pwd)) {
   // app.setAttribute("dblist", roleinfoDAO.getDBlist(userid));
   if (getServlet().getServletContext() != null) {
    getServlet().getServletContext().setAttribute("dblist",
      dbinfoDAO.getMap());
   }
  
   session.setAttribute("userid", userid);
   session.setAttribute("dblist",roleinfoDAO.findById(userid).getDblist());
   session.setAttribute("functionlist", roleinfoDAO.findById(userid)
     .getFunctionList());
//   System.out.print(userid);
   session.setAttribute("roleName", userid);
   return mapping.findForward("mainPage");
  }
  if (user == null) {
   ActionMessages messages = new ActionMessages();
   ActionMessage message = new ActionMessage("page.login.failure");
   messages.add(Globals.MESSAGE_KEY, message);
   saveErrors(request, messages);
   return new ActionForward(mapping.getInput());
  } else {
   return new ActionForward(mapping.getInput());
  }
}
}
 
评论列表
请选择道具
温馨提示:点击验证码输入框,以获取验证码
请输入验证码:
      
<script type="text/javascript"> //$1  于 $2 发表的评论
/x02").replace(//[//quote/]/g,"/x01"); for(var i=0;i<2;i++) s=s.replace(//x03([^/x03/x01/x02]*?)/x02([^/x03/x01/x02]*?)/x01/g, function(a,b,c){ return '
'+b+'引用内容:

'+c+'
'; }); return s.replace(/[/x03/x02/x01]/g,""); } var bLoaded = false; function checkMsgReply(obj) { if(!bLoaded) top.includeJS('/qzone/blog/script/common.js', function(){bLoaded=true;checkMsgReply(obj)}, document); else checkReply(obj); if(obj.checked){ MAX_COMMENT_LEN = 500; } else { MAX_COMMENT_LEN = 4500; } _fontCount = MAX_COMMENT_LEN; //字数限制 if(!window.sendCommentEditor) return; if(sendCommentEditor.editorArea.editMode == 1) toCountFont(sendCommentEditor.id, "html"); else toCountFont(sendCommentEditor.id, "text"); } function showMsgLeftCnt() { if(!bLoaded) top.includeJS('/qzone/blog/script/common.js', function(){bLoaded=true;showMsgLeftCnt();}, document); else showLeftSMS(); } function selectBlogPaper() { if(checkLogin() <= 10000) { top.showLoginBox("mall"); return; } if(!!top.g_JData["blogContent"]) { if(parent.g_iLoginUin == parent.g_iUin) { location.href="/qzone/newblog/blogeditor.html?paperid=" + parent.g_JData["blogContent"].data.lp_id + "&paperstyle=" + parent.g_JData["blogContent"].data.lp_style + "&paperdialog=1"; } else { parent.location.href="http://user.qzone.qq.com/" + parent.g_iLoginUin + "/addNewBlog?paperid=" + parent.g_JData["blogContent"].data.lp_id + "&paperstyle=" + parent.g_JData["blogContent"].data.lp_style; } } else { top.showMsgBox("抱歉,暂时无法获取该信纸信息!", 1, 2000); } } /** * 批量删除中选择全选 */ function selectAllComments(bChecked) { var oList = document.getElementsByName("commentCheckBox"); if(oList.length==0) return; for(var i=0; i 0){ dalert(null, parent.g_XDoc["delBatchReply"].xml, 2000); delete parent.g_XDoc["delBatchReply"]; return; } dalert(null, parent.g_XDoc["delBatchReply"].xml, 2000, 2); contentProperty.totalCommentNumber -= nDeleteCnt; //清理cache with(contentProperty){ delete parent.g_XDoc["blogRoot"].contentHSList[currentBlogid]; pageList = {}; pageIndexMap = []; currentCommentPage = lastCommentPage = (!contentProperty.nowaPage)?0:nowaPage[3]; parent.g_XDoc["blogRoot"].replyNumUpdateHSmap[currentBlogid] = totalCommentNumber; parent.isRefreshTop = true; if(currentCommentPage == 0) { setTimeout(contentInit, 1000); } else{ var tp = Math.ceil(totalCommentNumber/PAGE_COMMENT_NUM); var num = totalCommentNumber%PAGE_COMMENT_NUM; if(num==0 || currentCommentPage10000 && top.g_iLoginUin!=top.g_iUin) { $("msgboardSelfReply").style.display = ""; $("blogSelPaper").title = "我也要使用此信纸写日志"; } setTimeout(contentInit,50); //]]> </script>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值