我的第八课:错误总结

总流程:
index.jsp页面 :
    
        < s:form  action  = "PersonLogin"  method =  "post" >
                  < table  border  = "1"  bgcolor = "red" >
                       < tr  >
                             < th  >
                                  < s:textfield  name  = "uname"  label =  "用户名"    size  = "14" />
                             </ th >
                       </ tr >
                       < tr  >
                             < td  >
                                  < s:password  name  = "pwd"  label = "密码"  size =  "14" />
                             </ td >
                       </ tr >
                  </ table >
                  < s:submit  value  = "登陆"  align =  "center"  />
             </ s:form >
Struts-xml:
             <!-- 个人登陆 -->
             < action  name  = "PersonLogin"  class = "PersonLogin" >
                  < result  name  = "success"  > /WEB-INF/ jsp/person/main.jsp </ result  >
                  < result  name =  "input" > /WEB-INF/jsp/person/login.jsp </  result >
                  < result  name =  "error" > /WEB-INF/jsp/person/main.jsp </  result >          
             </ action >
applicationcontext.xml:  
    <!-- 个人登陆 -->
      < bean  id  = "PersonLogin"  class = "com.qzzp.action.PersonLogin"  scope =  "prototype" >
             < property  name  = "service"  ref =  "person_Service" ></ property  >
      </ bean  >
Action层:
      public  class  PersonLogin  extends  ActionSupport {
      private  Person  person ;
      private  Person_Service  service ;
      public  Person getPerson() {
            return  person ;
     }
      public  void  setPerson(Person person) {
            this .  person  = person;
     }
      public  Person_Service getService() {
            return  service ;
     }
      public  void  setService(Person_Service service) {
            this .  service  = service;
     }
      @Override
      public  String execute()  throws  Exception {
            int  id= this . service  .personLogin( person  .getUname(), person  .getPwd());
            if (id>0){
                return  SUCCESS ;
          }
            else  {
                return  ERROR ;
          }
              
     }

}
dao层:
  public  Person loginByNP(String uname, String pwd);  //个人登陆
dao impl 层:
        public  Person loginByNP(String uname, String pwd) {
            ht  = getHibernateTemplate();
           List personList =  ht .find(  "from Person person where person.uname=?and   person.pwd=?" ,  new  String[] { uname, pwd });
            if  (personList !=  null  && personList.size() >= 1) {
                return  (Person) personList.get(0);

          }

            return  null ;

     }

service层:
        public  int  personLogin(String uname,String pwd)  throws  Exception;
service Impl层:
           public  int  personLogin(String uname, String pwd)  throws  Exception {

            try  {
              Person person=  personDAO .loginByNP(uname, pwd);
                if (person!=  null )  return  person.getId();
          }  catch  (Exception e) {
              e.printStackTrace();
                throw  new  Exception(  "验证用户登陆时出现错误"  );
          }
            return  -1;
     }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值