JSP页面为什么只能获得学号和密码,性别和年龄获得不到

public String execute() {
if(studentService.loginVerify(sid, spassword)){
Student student = new Student();
student.setSid(sid);
student.setSpassword(spassword);
student.setSex(sex);
student.setSname(sname);
session.put("student", student);
return "success";
} else {
super.addActionError("用户名或密码不正确!");
return INPUT;
}
}

<% Student student=(Student)request.getSession().getAttribute("student");%>
    <h3>学号:<%=student.getSid()%></h3><br>
    <h3>姓名:<%=student.getSname()%></h3><br>
    <h3>性别:<%=student.getSex()%></h3><br>
        <h3>性别:<%=student.getSpassword()%></h3><br>   

在你的execute()方法里输出sex、sname,看控制台里是否有输出,如果为空那是你Service调用的实现类出错了,也就是dao层。

如果控制台正确输出,那可能就是你jsp页面获取出问题了,你可以麻烦一点,sex、sname都在脚本片段<%%>里先获取获取试试

student.setSex(sex);
student.setSname(sname);
这两个函数怎么实现的,还有sex sname是否正确