struts.xml配置文件:
<struts>
<package name="myaction" namespace="/" extends="struts-default">
<action name="userinfo" class="myaction.LoginAction">
<result name="login">login.jsp</result>
<result name="manage">manage.jsp</result>
<result name="xiaoshou">xiaoshou.jsp</result>
<result name="register">register.jsp</result>
</action>
</package>
</struts>
login.jsp登录界面
<form action="userinfo" method="post" >
用户名:<input type="text" name="eid"><br>
密 码:<input type="password" name="password"><br>
权 限:
<input type="radio" checked="checked" name ="aa">管理员
<input type="radio" name ="aa">销售员<br>
<input type="button" value="注册" οnclick="toRegist()">
<input type="submit" value="登录" >
</form>
loginaction:
package myaction;
import com.opensymphony.xwork2.ActionSupport;
import action.User;
import dao.LoginDao;
public class LoginAction extends ActionSupport{
private User ui;
private LoginDao dao = new LoginDao();
public User getUi() {
return ui;
}
public void setUi(User ui) {
this.ui = ui;
}
public String login(){
if(dao.login(ui)){
/*if("admin".equals(ui.getRole())){*/
return "manage";
/*}
else{
return "xiaoshou";
}*/
}else{
this.addFieldError("ui.eid", "错误");
return "login";
}
}
}
logindao:
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import action.User;
import until.JdbcUtil;
public class LoginDao{
public boolean login(User ui){
boolean flag = false;
ResultSet rs = JdbcUtil.querySql("select * from user2 where eid=? and password=?", ui.getEid(),ui.getPassword());
try {
while(rs.next()){
flag = true;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return flag;
}
}
也有实体类user.java到底是哪里的问题