当前位置: 首页>>代码示例>>Java>>正文


Java DynaActionForm.getString方法代码示例

本文整理汇总了Java中org.apache.struts.action.DynaActionForm.getString方法的典型用法代码示例。如果您正苦于以下问题:Java DynaActionForm.getString方法的具体用法?Java DynaActionForm.getString怎么用?Java DynaActionForm.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.struts.action.DynaActionForm的用法示例。


在下文中一共展示了DynaActionForm.getString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.struts.action.DynaActionForm; //导入方法依赖的package包/类
/**
 * This is the action called from the Struts framework.
 * @param mapping The ActionMapping used to select this instance.
 * @param form The optional ActionForm bean for this request.
 * @param request The HTTP Request we are processing.
 * @param response The HTTP Response we are processing.
 * @throws java.lang.Exception
 * @return
 */
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    DynaActionForm inputForm = (DynaActionForm) form;
    RestaurantManager manager = new RestaurantManager();
    String login = inputForm.getString("login");
    String password = inputForm.getString("password");
    UserInfo user = manager.findUser(login, password);
    if (user != null) {
        HttpSession session = request.getSession();
        session.setAttribute("user", user);
        return mapping.findForward(SUCCESS);
    }
    ActionMessages errors = new ActionErrors();
    ActionMessage msg = new ActionMessage("errors.loginfailed", "login/password");
    errors.add(ActionMessages.GLOBAL_MESSAGE, msg);
    saveErrors(request, errors);

    return mapping.findForward(FAILURE);

}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:33,代码来源:LoginAction.java

示例2: signIn

import org.apache.struts.action.DynaActionForm; //导入方法依赖的package包/类
private ActionForward signIn(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
try {
    DynaActionForm signupForm = (DynaActionForm) form;

    // validation
    ActionMessages errors = validateSignin(signupForm);
    if (!errors.isEmpty()) {
	saveErrors(request, errors);
	return mapping.findForward("signup");
    } else {
	String login = signupForm.getString("usernameTab2");
	String password = signupForm.getString("passwordTab2");
	String context = signupForm.getString("context");
	SignupAction.signupService.signinUser(login, context);

	HttpSession hses = request.getSession();
	hses.setAttribute("login", login);
	hses.setAttribute("password", password);
	response.sendRedirect("/lams/login.jsp?redirectURL=/lams");
	return null;
    }
} catch (Exception e) {
    SignupAction.log.error(e.getMessage(), e);
    request.setAttribute("error", e.getMessage());
}

return mapping.findForward("index");
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:SignupAction.java

示例3: validateSignin

import org.apache.struts.action.DynaActionForm; //导入方法依赖的package包/类
private ActionMessages validateSignin(DynaActionForm signupForm) {
ActionMessages errors = new ActionMessages();
if (StringUtils.isBlank(signupForm.getString("usernameTab2"))) {
    errors.add("usernameTab2", new ActionMessage("error.username.blank"));
}
if (StringUtils.isBlank(signupForm.getString("passwordTab2"))) {
    errors.add("passwordTab2", new ActionMessage("error.password.blank"));
}
if (!SignupAction.signupService.courseKeyIsValid(signupForm.getString("context"),
	signupForm.getString("courseKeyTab2"))) {
    errors.add("courseKeyTab2", new ActionMessage("error.course.key.invalid"));
}

if (errors.isEmpty()) {
    String login = signupForm.getString("usernameTab2");
    String password = signupForm.getString("passwordTab2");
    User user = SignupAction.signupService.getUserByLogin(login);
    if (user == null) {
	errors.add("usernameTab2", new ActionMessage("error.login.or.password.incorrect",
		"<a onclick='selectSignupTab();' id='selectLoginTabA'>", "</a>"));
    } else {
	String passwordHash = user.getPassword().length() == HashUtil.SHA1_HEX_LENGTH ? HashUtil.sha1(password)
		: HashUtil.sha256(password, user.getSalt());
	if (!user.getPassword().equals(passwordHash)) {
	    errors.add("usernameTab2", new ActionMessage("error.login.or.password.incorrect",
		    "<a onclick='selectSignupTab();' id='selectLoginTabA'>", "</a>"));
	}
    }
}

return errors;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:SignupAction.java


注:本文中的org.apache.struts.action.DynaActionForm.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。