📄 mainaction.java
字号:
package stock.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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 data.ChaXunData;
import stock.ErrMsg.ErrMsg;
import stock.data.dto.inDto.LoginInDto;
import stock.data.dto.inDto.MainInDto;
import stock.data.dto.outDto.LoginOutDto;
import stock.data.dto.outDto.MainOutDto;
import stock.form.LoginForm;
import stock.form.MainForm;
/*
* Created on 2006-12-29
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author hyron yuhui
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class MainAction extends Action {
private int forward;
String ToGB2312(String s) {
try {
return new String(s.getBytes("ISO-8859-1"), "GB2312");
} catch (Exception e) {
return null;
}
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
MainForm main = (MainForm) form;
MainOutDto mainOutDto = new MainOutDto();
MainInDto mainInDto = new MainInDto();
try {
CheckInput(main, mainOutDto, mainInDto);
} catch (Exception e) {
forward = 0;
if (main.getUserName().equals("")) {
ErrMsg.ErrMsgOfLogin = "Input UserName!";
} else {
ErrMsg.ErrMsgOfLogin = "The User Not Exist!";
}
}
if (forward == 1) {
ErrMsg.ErrMsgOfLogin = "";
return mapping.findForward("success");
} else {
return mapping.findForward("failure");
}
}
public void CheckInput(ActionForm form, MainOutDto mainOutDto,
MainInDto mainInDto) {
MainForm main = (MainForm) form;
if (!main.isRegister()) {
mainInDto.setUserName(main.getUserName());
mainOutDto.setInDto(mainInDto);
if (mainInDto.getUserPsw().equals(null)
|| mainInDto.getUserPsw().equals("")) {
forward = -1;
ErrMsg.ErrMsgOfLogin = "Input Password!";
} else if (main.getUserPsw().equals("")) {
forward = -1;
ErrMsg.ErrMsgOfLogin = "Input Password!";
} else if (mainInDto.getUserPsw().equals(main.getUserPsw())) {
forward = 1;
} else {
forward = 0;
ErrMsg.ErrMsgOfLogin = "The Password Is Not Correct!";
}
} else {
main.setRegister(false);
forward = 1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -