1. Injection Properties
Direct Injection Properties:
Public String userName;
Public String GetUserName () {return
userName;
}
public void Setusername (String userName) {
this.username = userName;
}
@Override public
String execute () throws Exception {
//TODO auto-generated A stub
user user = new use R ();
User.setusername (UserName)//Here you need to receive and use UserName.
Userdao dao = new Userdao ();
HttpServletResponse response= servletactioncontext.getresponse ();
PrintWriter out = Response.getwriter ();
if (dao.checkexists (user))
{
out.print ("");
}
else
{
out.print ("");
}
return null;
}
2.Domain model This is the usual way
There's no repetition here,
3. Modeldriven
The third method is not commonly used, only need to understand;
The process is divided into 4 steps:
(1) Action Implementation Modeldriven<user> interface
(2) Adding abstract methods
(3) Definition and initialization of a model
User User=new user ();
(4) Generating setters and getter
public class Checkuseraction extends Actionsupport implements modeldriven<user>{
Private User user = new user () ;
Public User GetUser () {return
user;
}
public void SetUser (user user) {
this.user = user
}
@Override public
String execute () throws Exception {
//TODO auto-generated method stub
Userdao dao = new Us Erdao ();
HttpServletResponse response= servletactioncontext.getresponse ();
PrintWriter out = Response.getwriter ();
if (dao.checkexists (user))
{
out.print ("");
}
else
{
out.print ("");
}
return null;
}
@Override public
User Getmodel () {
//TODO auto-generated A stub return
user
}
Note: When using methods 1 and 3, the front-end and JSP code portions need not be changed because they are directly called username properties.
Method 2 needs to change the username in jquery into User.username.