📄 csdn_struts原理与应用(三).htm
字号:
else {
user = getUser(database, username);
if ((user != null) && !user.getPassword().equals(password))
user = null;
if (user == null)
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.password.mismatch"));
}
// Report any errors we have discovered back to the original form
if (!errors.isEmpty()) {
saveErrors(request, errors);
return (mapping.getInputForward());
}
// Save our logged-in user in the session
HttpSession session = request.getSession();
session.setAttribute(Constants.USER_KEY, user);
if (log.isDebugEnabled()) {
log.debug("LogonAction: User '" + user.getUsername() +
"' logged on in session " + session.getId());
}
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
// Forward control to the specified success URI
return (mapping.findForward("success"));
}
/**
* Look up the user, throwing an exception to simulate business logic
* rule exceptions.
*
* @param database Database in which to look up the user
* @param username Username specified on the logon form
*
* @exception ModuleException if a business logic rule is violated
*/
public User getUser(UserDatabase database, String username)
throws ModuleException {
// Force an ArithmeticException which can be handled explicitly
if ("arithmetic".equals(username)) {
throw new ArithmeticException();
}
// Force an application-specific exception which can be handled
if ("expired".equals(username)) {
throw new ExpiredPasswordException(username);
}
// Look up and return the specified user
return ((User) database.findUser(username));
}
}
</TEXTAREA> </P><A
href="http://localhost:83/index.jsp"></A></FONT><BR><!--内容结束//--></TD></TR></TBODY></TABLE><BR>
<TABLE width=600 border=0>
<TBODY>
<TR>
<TD>作者相关文章:
<LI><A href="http://www.csdn.net/develop/article/22/22753.shtm"
target=_blank>DOM4J 使用简介<FONT color=#ff0000>(原作)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22574.shtm"
target=_blank>Struts原理与应用(完)<FONT color=#ff0000>(原作)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22572.shtm"
target=_blank>Struts原理与应用(二)<FONT color=#ff0000>(原作)</FONT></A>
</LI></TD></TR></TBODY></TABLE><BR>
<TABLE width=600 border=0>
<TBODY>
<TR>
<TD>其它相关文章:
<LI><A href="http://www.csdn.net/develop/article/22/22722.shtm"
target=_blank>强烈推荐一篇文章及其评论 关于MVC等方面<FONT
color=#ff0000>(原作)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22536.shtm"
target=_blank>Tiles傻瓜式入门―hajavaor―<FONT
color=#ff0000>(原作)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22255.shtm"
target=_blank>Java Web应用测试指导<FONT color=#ff0000>(原作)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22176.shtm"
target=_blank>Struts tags (3) ----Bean(2)<FONT
color=#ff0000>(翻译)</FONT></A>
<LI><A href="http://www.csdn.net/develop/article/22/22175.shtm"
target=_blank>Struts tags (2) ----Bean(1)<FONT
color=#ff0000>(翻译)</FONT></A> </LI></TD></TR></TBODY></TABLE><BR>
<TR></TD></TR></TBODY></TABLE><BR><!--文章评论开始//-->
<TABLE cellSpacing=0 cellPadding=0 width=770 align=center bgColor=#006699
border=0>
<TBODY>
<TR bgColor=#006699>
<TD id=white align=middle bgColor=#006699><FONT
color=#ffffff>对该文的评论</FONT></TD>
<TD align=middle><!--文章人气开始//-->
<SCRIPT src="CSDN_Struts原理与应用(三).files/readnum.htm"></SCRIPT>
<!--文章人气开始//--></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=2 width=770 align=center bgColor=#666666
border=0>
<TBODY>
<TR>
<TD bgColor=#cccccc colSpan=3><SPAN style="COLOR: #990000"><IMG height=16
hspace=1 src="CSDN_Struts原理与应用(三).files/ico_pencil.gif" width=16>
</SPAN> Mai_520<I>(2003-12-17 17:36:01)</I> </TD></TR>
<TR>
<TD width=532 bgColor=#ffffff
colSpan=3><BR>action只是把大量的业务逻辑进行整合的地方,并不进行具体的业务逻辑操作<BR></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=2 width=770 align=center bgColor=#666666
border=0>
<TBODY>
<TR>
<TD bgColor=#cccccc colSpan=3><SPAN style="COLOR: #990000"><IMG height=16
hspace=1 src="CSDN_Struts原理与应用(三).files/ico_pencil.gif" width=16>
</SPAN> icecloud<I>(2003-12-16 13:06:18)</I>
</TD></TR>
<TR>
<TD width=532 bgColor=#ffffff colSpan=3><BR>to
guanshengyong<BR>这是一个设计问题,action只处理request并调用facade层,不应该包含具体逻辑。<BR>比如处理登陆,不能在这里访问数据库,并判断是否存在某用户,而应该是把这段封装在一个facade的validateUser方法中。
<BR><BR>大概就是这样<BR></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=2 width=770 align=center bgColor=#666666
border=0>
<TBODY>
<TR>
<TD bgColor=#cccccc colSpan=3><SPAN style="COLOR: #990000"><IMG height=16
hspace=1 src="CSDN_Struts原理与应用(三).files/ico_pencil.gif" width=16>
</SPAN> guanshengyong<I>(2003-12-15 22:51:55)</I>
</TD></TR>
<TR>
<TD width=532 bgColor=#ffffff
colSpan=3><BR>不把大量的业务逻辑写在了action中,应该写在什么地方?不太懂<BR></TD></TR></TBODY></TABLE>
<SCRIPT language=javascript>
<!--
function isEmpty(s)
{
return ((s == null) || (s.length == 0))
}
function submit1()
{
if (document.add_critique.csdnpassword.value != '_xxx_no')
{
if (isEmpty(document.add_critique.csdnname.value) || isEmpty(document.add_critique.csdnpassword.value) || isEmpty(document.add_critique.critique_content.value))
{
alert('登陆名,密码,评论不能为空!!!!') ;
return false;
}
}
else
{
if ( isEmpty(document.add_critique.critique_content.value))
{
alert('评论不能为空!!!!') ;
return false;
}
}
add_critique.ubmit.disabled =true;
document.add_critique.submit();
}
//-->
</SCRIPT>
<BR><BR>
<TABLE cellSpacing=1 cellPadding=2 width=770 align=center bgColor=#cccccc
border=0>
<TBODY>
<TR>
<TH id=white bgColor=#006699><FONT
color=#ffffff>发表评论</FONT></TH></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=2 width=770 align=center bgColor=#ffffff
border=0>
<TBODY>
<TR>
<TD>
<FORM name=add_critique action=/develop/critique_Sql.asp
method=post><INPUT type=hidden value=add name=critique_add>
<SCRIPT>
function getcookieval(offset) {
var endstr = document.cookie.indexOf(';',offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape (document.cookie.substring(offset,endstr));
}
function getcookie(name) {
var arg = name + '=';
var alen = arg.length;
var clen = document.cookie.length;
var j = 0;
while (j< clen) {
var k = j + alen;
if(document.cookie.substring(j,k) == arg) return getcookieval(k);
j = document.cookie.indexOf('',j)+1;
if (j ==0 ) break;
}
return null;
}
var ss = getcookie('userid');
if ((ss==null) | (ss=='2'))
{
document.write('<font color=red><B>你还没有登录:</B></font>昵称:<input type=text name=csdnname size=10 class=from1> 密码:<input type=password name=csdnpassword size=10 class=from1> <a href=http://www.csdn.net/expert/zc.asp><B>免费注册</B></a>');
}
else
{
document.write('<input type=hidden name=csdnname size=10 value=><input type=hidden name=csdnpassword size=10 value=_xxx_no>')
}
</SCRIPT>
评论:<BR> <TEXTAREA name=critique_content rows=8 cols=100></TEXTAREA><BR>
<INPUT onclick=javascript:submit1(); type=button value=发表评论 name=ubmit>
<INPUT type=hidden value=22573 name=Topic_id> <INPUT type=hidden
value=/Develop/Build_Article.asp?id=22573 name=From>
</FORM></TD></TR></TBODY></TABLE>
<CENTER></CENTER><BR>
<HR width=770 noShade SIZE=1>
<TABLE cellSpacing=0 cellPadding=0 width=500 border=0>
<TBODY>
<TR align=middle>
<TD vAlign=bottom height=10><A
href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A
href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A
href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A
href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A
href="http://www.csdn.net/english">English</A> </TD>
<TD align=middle rowSpan=3><A
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG
height=48 src="CSDN_Struts原理与应用(三).files/biaoshi.gif" width=40
border=0></A></TD></TR>
<TR align=middle>
<TD vAlign=top>百联美达美公司 版权所有 京ICP证020026号</TD></TR>
<TR align=middle>
<TD vAlign=top><FONT face=Verdana>Copyright © CSDN.net, Inc. All rights
reserved</FONT></TD></TR>
<TR>
<TD height=15></TD>
<TD></TD></TR></TBODY></TABLE></DIV><!--61.175.234.206//--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -