?? loginaction.java
字號:
package com.wish.jhk.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 com.wish.jhk.action.form.LoginForm;
import com.wish.jhk.service.AuctionManager;
import com.wish.jhk.service.impl.AuctionManagerImpl;
import com.wish.jhk.util.BeanFactory;
public class LoginAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse resp) throws Exception {
ActionForward forward = new ActionForward();
LoginForm loginform = (LoginForm) form;
String username = loginform.getUsername();
String password = loginform.getPassword();
AuctionManager auctionmanager = (AuctionManagerImpl) BeanFactory
.getBean("auctionmanager");
try {
// AuctionManagerImpl auctionmanager = new AuctionManagerImpl();
Integer userId = auctionmanager.validLogin(username, password);
if (userId != null) {
req.getSession().setAttribute("userId", userId);
// System.out.println("---------"+req.getHeader("regerer")+"/login.jsp");
forward.setPath("/viewjsp/main.jsp");
} else {
req.setAttribute("username", loginform.getUsername());
forward.setPath("/error.jsp");
}
} catch (Exception e) {
e.printStackTrace();
req.setAttribute("exception", e.getMessage());
// System.out.println("-------------------------------");
// System.out.println(e.getMessage());
forward.setPath("/error.jsp");
}
return forward;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -