|
What I did was the login interface of the test system, and the following problems occurred:
Please take a look at some of my interception code first:
1. Login interface (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> Examination system data management login window </ 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">
Manage account:
<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">
Management password:
<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 = "OK" styleClass = "Sborder"> </ html: submit>
<html: reset property = "reset" styleClass = "Sborder" value = "rewrite"> </ html: reset>
</ div>
</ td>
</ tr>
</ table>
</ html: form>
..............................
2. Specific verification 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 ();
// call the method of the model
LoginDAO dao = new LoginDAO ();
Bean_admin admin = dao.getAdmin (username);
ActionErrors errors = new ActionErrors ();
// get a reference to the session object
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 file
# 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>
The problem now is that when the user name and password are both wrong, there is no error message, but a blank interface is transferred ...
What do you think is wrong with me ??????????? |
|