新手关于struts2 的问题 急!!
我在action类中为什么得不到jsp中的student值,报nullpoint,已经确信调用到了action,哪位大哥解答一下,谢谢!!
action:
package my.struts;
import my.dao.dao.*;
import my.model.db.*;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private StudentDao sdao;
private Student student;
public String execute() throws Exception{
// student = new Student();
// student.setMatricNo("mat001");
System.out.println("in method "+student.getMatricNo());
if(checkStudent(student)){
return SUCCESS;
}else{
return INPUT;
}
}
private void setSdao(StudentDao sdao) {
this.sdao = sdao;
}
private StudentDao getSdao() {
return sdao;
}
private void setS(Student student) {
this.student = student;
}
private Student getS() {
return student;
}
private Boolean checkStudent(Student s){
System.out.println("before");
sdao=DaoFactory.getInstance().getStudentDAO();
Student sTem= new Student();
sTem = sdao.findStudent(s.getMatricNo());
System.out.println("after");
if(sTem.getEmail()==s.getEmail()){
return true;
}else{
return false;
}
}
private void setNo(String no) {
this.no = no;
}
private String getNo() {
return no;
}
private void setPassword(String password) {
this.password = password;
}
private String getPassword() {
return password;
}
}
jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<s:form action="loginAction" >
<s:textfield name="student.matricNo" label="MatricNo" />
<s:password name="student.email" label="Password" />
<s:submit />
</s:form>
</body>
</html>