📄 studentloginaction.java
字号:
package edu.yinhe.mis.control;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import edu.yinhe.mis.dto.StudentLoginDTO;
import edu.yinhe.mis.vo.StudentLoginVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;
/**
* @author 姜敏
*/
public class StudentLoginAction extends BaseAction{
/**
* 登录
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
StudentLoginForm slForm=(StudentLoginForm) form;
StudentLoginDTO sldto =new StudentLoginDTO();
ActionForward forward=mapping.findForward("error");
try {
BeanUtils.copyProperties(sldto,slForm);
service.setDataSource(this.getDataSource(request,"mydatasource"));
StudentLoginVO slvo = (StudentLoginVO) service.load(sldto);
if(slvo!=null)
{
session.setAttribute("login", slvo);
forward=mapping.findForward("login");
}else{
forward = mapping.findForward("error");
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
/**
* 修改密码
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward updatepwd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
StudentLoginForm studentloginForm=(StudentLoginForm) form;
StudentLoginDTO studentloginDTO =new StudentLoginDTO();
ActionForward forward=mapping.findForward("error");
try {
BeanUtils.copyProperties(studentloginDTO,studentloginForm);
service.setDataSource(this.getDataSource(request,"mydatasource"));
service.modify(studentloginDTO);
forward=mapping.findForward("updateSuccess");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -