Spring+Struts2整合(2)
if("zhangsan".equals(username)&&"123".equals(password)){
return true;
}else{
return false;
}
}
}
LoginAction
package com.itmyhome.actioin;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String username;
private String password;
private LoginDao loginDao; //此DAO交给spring来处理
public String execute(){
if(loginDao.login(username, password)){
return "success";
}else{
return "input";
}
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public LoginDao getLoginDao() {
return loginDao;
}
public void setLoginDao(LoginDao loginDao) {
this.loginDao = loginDao;
}
}
struts.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>