|
我做的是考试系统的登陆界面,出现了以下问题:
请大家先看一下我的部分截取代码:
1.登陆界面(main.jsp)
............................
<html:form action="/login1.do" focus="username">
<html:hidden property="usertype" value="1" />
<table width="100%" height="1002%" border="0" bgcolor="#FFFFFF" class="Xsmall">
<tr>
<td height="60">
<div align="center">
<strong>考试系统数据管理登录窗口</strong>
</div>
<div align="center">
<strong><html:errors property="error"/></strong>
</div>
</td>
</tr>
<tr>
<td height="26">
<div align="center">
<img src="/exam/img/stu_1.gif" width="16" height="16" align="absmiddle">
管理帐号:
<html:text property="username" styleClass="Sborder" styleId="saname" size="12" maxlength="20" /><strong><html:errors property="username"/></strong>
</div>
</td>
</tr>
<tr>
<td height="26">
<div align="center">
<img src="/exam/img/useronline.gif" width="16" height="16" align="absmiddle">
管理密码:
<html:password property="password" styleClass="Sborder" styleId="saps" size="12" maxlength="20" redisplay="false" /><strong><html:errors property="password"/></strong>
</div>
</td>
</tr>
<tr>
<td height="26">
<div align="center">
<html:submit property="submit" value="确 定" styleClass="Sborder"></html:submit>
<html:reset property="reset" styleClass="Sborder" value="重 写"></html:reset>
</div>
</td>
</tr>
</table>
</html:form>
..............................
2.具体验证action(loginaction):
..............................
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Login1Form login1Form = (Login1Form) form;// TODO Auto-generated
// method stub\
String username = login1Form.getUsername();
String password = login1Form.getPassword();
String usertype = login1Form.getUsertype();
// 调用模型的方法
LoginDAO dao = new LoginDAO();
Bean_admin admin = dao.getAdmin(username);
ActionErrors errors = new ActionErrors();
// 获得session对象的引用
HttpSession session = request.getSession();
if (admin == null) {
ActionError error = new ActionError("login.error");
errors.add("error", error);
this.saveErrors(request, errors);
return mapping.findForward(mapping.getInput());
} else {
if (admin.getPassword().equals(password)) {
session.setAttribute("user", username);
return mapping.findForward("suc");
} else {
ActionError error = new ActionError("login.password.error");
errors.add("password", error);
this.saveErrors(request, errors);
return new ActionForward(mapping.getInput());
}
}
3.property文件
# Resources for parameter 'com.neusoft.struts.ApplicationResources'
# Project P/exam
#Login1Form
username.null=<li>username is null</li>
password.null=<li>password is null</li>
#LoginAction
login.username.error=<li>username is error</li>
login.password.error=<li>password is error</li>
##struts-config.xml
#LoginAction------ExamException
login.error=<li>login is error! please try again</li>
#Exception error
error.key=<li>error try again</li>
#QuestionAction------ExamException
questionlist.query.error=<li>query is error</li>
#QuestionDelAction------ExamException
questionlist.delete.error=<li>delete is error</li>
#ExamRequestProcessor-------processPreprocess
no.login=<li>please login now</li>
现在出现的问题是,当用户名和密码都出入出错的时候,不出现错误提示,而是转移到了一个空白界面..........!
您看我是哪里出毛病了??????????? |
|