| |

VerySource

 Forgot password?
 Register
Search
View: 716|Reply: 3

A question encountered in struts !! Please take a look and help me solve it!

[Copy link]

2

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-23 09:20:01
| Show all posts |Read mode
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 ???????????
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-12 11:15:01
| Show all posts
Do your web.xml and struts-config.xml indicate the location of this resource file? Or do you declare that you want to use this resource file?
Reply

Use magic Report

2

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-2-14 18:15:02
| Show all posts
Can you be more specific? upstairs
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-5-7 13:15:01
| Show all posts
return new ActionForward (mapping.getInput ());
Did you set up the input page
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list