当前位置: 代码迷 >> J2EE >> 有个有关问题请大神帮助解决一下?
  详细解决方案

有个有关问题请大神帮助解决一下?

热度:85   发布时间:2016-04-21 21:01:08.0
有个问题请大神帮助解决一下??
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    
    <title>内容管理系统之用户注册</title>
    <style type="text/css">
    <!--
    .style1{
    color:#FF0000
    font-weight:bold
    }
    -->
</style>

  </head>
  
  <body>
   <!-- 该表单的提交要 通过regedit.action-->
   
   <form name="user" action="regedit.action" method="post">
   <table width="776" border="1">
   <tr>
    <td colspan="2">
    <div align="center">
     用户注册【<span class="style1">消息提示:${regedit.msg} </span>】
     </div>
     </td>
     </tr>
     
     <tr>
     <td>
      <div align="right">
      用户名:
      </div>
      </td>
      <td>
      <input type="text" name="username" value="${user.username}"/>
      </td>
      </tr> 
      <tr>
      <td>
      <div align="right">
      密码:
      </div>
      </td>
      <td>
      <input type="password" name="password" value="${user.password} "/>
      </td>
      </tr>
      <tr>
      <td colspan="2">
     
      <div align="center">
      <input type="submit" name="submit" value="提交">
     
      <input type="reset" name="Submit" value="重置"/>
      </div>
      </td>
      </tr>
      </table>
     </form>
     
  </body>
</html>
这是我的JSP页面,为注册页面
下面是RegeditAction.java
import java.io.IOException;
import java.sql.SQLException;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.ModelAndView;

import com.myEdition.bean.User;
import com.myEdition.dao.UserDAO;
import com.myEdition.dao.impl.UserDAOImpl;
import com.myEdition.domain.Regedit;
import com.myEdition.domain.impl.Regeditlmpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
@Controller("RegeditAction")

@Scope("prototype")
public class RegeditAction extends ActionSupport {

//定义接口Regedit
@Resource

private  User user;
private Regeditlmpl RegeditImpl;

public User getUser(){
return user;
}

public void setUser(User user){
this.user=user;

}
public String execute(){
//保存用户提交的信息
User user1 = RegeditImpl.find(user.getPassword(), user.getUsername());
if(user!=null){
Map session=(Map)ActionContext.getContext().getSession();
session.put("user1", user1);
RegeditImpl.saveUser(user);
//User user1 = RegeditImpl.find(user.getPassword(), user.getUsername());

return "regedit";
//返回页面
}
else 
return null;

}
public Regeditlmpl getRegeditImpl() {
return RegeditImpl;
}

public void setRegeditImpl(Regeditlmpl regeditImpl) {
RegeditImpl = regeditImpl;
}

为什么User user1 = RegeditImpl.find(user.getPassword(), user.getUsername());会是空指针呢?怎样才能获得JSP页面提交的参数呢?
  相关解决方案