⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginaction.java

📁 信息发布 发布系统 动态的菜单 和 信息统计
💻 JAVA
字号:
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl

package com.xuntian.material.action.portal;

import java.util.List;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.xuntian.material.bean.ItemBean;
import com.xuntian.material.bean.MsgBean;
import com.xuntian.material.bean.UserBean;
import com.xuntian.material.bean.entity.MsgEntity;
import com.xuntian.material.exception.BaseInfoException;
import com.xuntian.material.exception.ConnectPoolException;
import com.xuntian.material.exception.PortalException;
import com.xuntian.material.model.iservice.portal.IUserLogin;
import com.xuntian.material.model.service.BaseService;
import com.xuntian.material.model.service.baseinfo.MsgService;
import com.xuntian.material.model.service.portal.UserLogin;
import com.xuntian.material.struts.MAction;
import com.xuntian.material.util.Constants;

public class LoginAction extends MAction {
    public ActionForward login(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws PortalException {
        UserBean user = (UserBean) form;
        IUserLogin userLoginService = UserLogin.getInstance();
        if (userLoginService.isUserLogin(user)) {
            HttpSession session = request.getSession();
            session.setAttribute(Constants.SESSION_USER, user);
            return mapping.findForward("frame");
        } else {
            return mapping.findForward("welcome");
        }
    }

    public ActionForward logout(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        HttpSession session = request.getSession();
        session.invalidate();
        return mapping.findForward("welcome");
    }

    public ActionForward top(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
    		BaseService itemService = new MsgService();
    		List<String> item=new MsgEntity(null).listitem();
    		StringBuffer list=new StringBuffer("  |  ");
    		if(item!=null){
        	for(String ite:item){
        		list.append("<a href=");
        		list.append(request.getContextPath());
        		list.append(ite);
        	}
         	
        }
        
        request.setAttribute("baseinfo.orag.item", list.toString());
        return mapping.findForward("top");
    }

    public ActionForward main(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)  {
    	          
        	List<List<String>> data=null;
			try {
				data = new MsgEntity(null).queryAll();
			} catch (ConnectPoolException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            request.setAttribute("search.list.data", data);
        return mapping.findForward("main");
    }

    public ActionForward password(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        return mapping.findForward("password");
    }

    public ActionForward baseinfo(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws PortalException {
        UserLogin.getInstance().fill(request, form);
        return mapping.findForward("baseinfo");
    }

    public ActionForward save(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws PortalException {
        int result = UserLogin.getInstance().save(request, form);
        if (result > 0) {
            String url = "/Login.do?method=main";
            return successForward(request, mapping, "保存成功!", url);
        } else if (result == -2) {
            String message = "原始密码不正确!";
            return warningForward(request, mapping, message);
        } else {
            return warningForward(request, mapping, "保存失败!");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -