新手关于struts2 的问题 急!!

shi02022211 2008-07-19 10:49:26
我在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>
...全文
61 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧