loginexec.java
来自「BEA WebLogic Server 8.1大全 = BEA webLogic」· Java 代码 · 共 42 行
JAVA
42 行
package myApp.Action;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import java.util.Hashtable;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class LoginExec extends Action {
public ActionForward
execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
/* Example code if the user enters in 1234 for CustomerNo and password
* the page will be forwarded to orderlistentry else an action error is added
* displayed back to the front page
*/
HttpSession session = request.getSession();
if("1234".equals(request.getParameter("customerNo")) && "1234".equals(request.getParameter("password"))){
request.getSession().setAttribute("order",new java.util.Vector());
request.getSession().setAttribute("user",request.getParameter("customerNo"));
return mapping.findForward("success");
}
//add an error to be displayed at the front page
ActionErrors errors = new ActionErrors();
errors.add("loginerror", new ActionError("error.invalid.login", request.getParameter("customerNo")));
super.saveErrors(request, errors);
return mapping.getInputForward();
}
}//end of LoginExec
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?