请各位高手指点 小弟初学 上午写了个SSH架构下的小功能 但是老报空指针异常 找不出问题出哪里了,寒死。
/*-----------------------Action文件---------------*/publicclassLogonActionextendsStruts...
/*-----------------------Action文件---------------*/
public class LogonAction extends StrutsAction{
private static String LOGONSUCSSES ="logonsucsses";
private static String LOGONERROR ="logonerror";
private static String QUIT = "quit";
private LogonServiceImpl logonServiceImpl;
public ActionForward logon(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
String usn = (String)((LogonForm)form).getUsername();
String pwd = (String)((LogonForm)form).getPassword();
System.out.println(usn+" 000000000000000 "+pwd);
if(logonServiceImpl.goLog(usn,pwd)){
return mapping.findForward(LOGONSUCSSES);
}else
return mapping.findForward(LOGONERROR);
}
public ActionForward quit(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
return mapping.findForward(QUIT);
}
}
/*---------------------------------------service文件:----------------------------------------*/
public class LogonServiceImpl implements LogonService{
private LogonDAO logonDAO;
public boolean goLog(String username,String password){
if(username != null && !"".equals(username.trim()) && password !=null && !"".equals(password.trim())){
Logon logon = logonDAO.logQry(username);
String un = logon.getUsername();
String pd = logon.getPassword();
if(un.trim().equals(username.trim()) && pd.trim().equals(password.trim())){
return true;
}
System.out.println(un+"++++++++++++++++++"+pd);
}
return false;
}
}
/*------------------------------DAO-------------------------------*/
public class LogonDAO extends HibernateDaoSupport implements IlogonDAO {
private JdbcTemplate jdbcTemplate;
public Logon logQry(String username){
Logon po = (Logon)getHibernateTemplate().get(Logon.class, username);
return po;
}
}
ps:通过接口暴露的方法,不晓得这个写对没有,如果有错也请高手指出 拜谢!! 展开
public class LogonAction extends StrutsAction{
private static String LOGONSUCSSES ="logonsucsses";
private static String LOGONERROR ="logonerror";
private static String QUIT = "quit";
private LogonServiceImpl logonServiceImpl;
public ActionForward logon(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
String usn = (String)((LogonForm)form).getUsername();
String pwd = (String)((LogonForm)form).getPassword();
System.out.println(usn+" 000000000000000 "+pwd);
if(logonServiceImpl.goLog(usn,pwd)){
return mapping.findForward(LOGONSUCSSES);
}else
return mapping.findForward(LOGONERROR);
}
public ActionForward quit(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response){
return mapping.findForward(QUIT);
}
}
/*---------------------------------------service文件:----------------------------------------*/
public class LogonServiceImpl implements LogonService{
private LogonDAO logonDAO;
public boolean goLog(String username,String password){
if(username != null && !"".equals(username.trim()) && password !=null && !"".equals(password.trim())){
Logon logon = logonDAO.logQry(username);
String un = logon.getUsername();
String pd = logon.getPassword();
if(un.trim().equals(username.trim()) && pd.trim().equals(password.trim())){
return true;
}
System.out.println(un+"++++++++++++++++++"+pd);
}
return false;
}
}
/*------------------------------DAO-------------------------------*/
public class LogonDAO extends HibernateDaoSupport implements IlogonDAO {
private JdbcTemplate jdbcTemplate;
public Logon logQry(String username){
Logon po = (Logon)getHibernateTemplate().get(Logon.class, username);
return po;
}
}
ps:通过接口暴露的方法,不晓得这个写对没有,如果有错也请高手指出 拜谢!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询