盘绰网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

半翻译半整理的一些struts的东东,很浅显的,欢迎指正(4)

时间:2024/12/15作者:未知来源:盘绰网教程人气:


[摘要](password.length() == 0) ) errors.add("password",new ActionError("errors.password.re...
(password.length() == 0) ) {
errors.add("password",new ActionError("errors.password.required"));
}
return errors;
}
…………………
}

Action类:
public class LoginAction extends Action {
……………………
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request, HttpServletResponseresponse) throws IOException, ServletException {
String user = null;
// Default target to success
String target = "success";
// Use the LoginForm to get the request parameters
String username = ((LoginForm)form).getUsername();
String password = ((LoginForm)form).getPassword();
user = getUser(username, password);
// Set the target to failure
if ( user == null ) {
target = "login";
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("errors.login.unknown",username));
// Report any errors we have discovered back to the
// original form
if (!errors.empty()) {
saveErrors(request, errors);
}
}
else {
HttpSession session = request.getSession();
session.setAttribute("USER", user);
}
// Forward to the appropriate View
return (mapping.findForward(target));
}
}
在表现层中表现错误只须要写上<html:error />标签即可。

关键词:  半翻译半整理的一些struts的东东  很浅显的  欢迎指正(4)





Copyright © 2012-2018 盘绰网教程(http://www.panchuo.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版