package  cn.userlogin.dao;

import  java.util.List;

public   interface  userloginDAO  {
   
public List getUser(String username,String password);
}

package  cn.userlogin.dao.impl;

import  java.util.List;

import  org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import  cn.userlogin.dao.userloginDAO;

public   class  userloginDAOimpl  extends  HibernateDaoSupport  implements
        userloginDAO 
{

    
public List getUser(String username, String password) {
        String queryString 
= "from Loginuser where username=" + username
                
+ "and password=" + password + "";
        
return this.getHibernateTemplate().find(queryString);
    }


}
/**/ /*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 
*/

package  cn.userlogin.struts.action;

import  java.util.List;

import  javax.servlet.http.HttpServletRequest;
import  javax.servlet.http.HttpServletResponse;

import  org.apache.struts.action.ActionForm;
import  org.apache.struts.action.ActionForward;
import  org.apache.struts.action.ActionMapping;
import  org.apache.struts.actions.DispatchAction;
import  org.apache.struts.validator.DynaValidatorForm;
import  org.springframework.context.ApplicationContext;
import  org.springframework.context.support.ClassPathXmlApplicationContext;

import  cn.userlogin.dao.impl.userloginDAOimpl;

/** */ /**
 * MyEclipse Struts Creation date: 05-31-2009
 * 
 * XDoclet definition:
 * 
 * @struts.action path="/userlogin" name="userloginForm" input="/login.jsp"
 *                parameter="method" scope="request" validate="true"
 
*/

public   class  UserloginAction  extends  DispatchAction  {
    
/**//*
     * Generated Methods
     
*/


    
/** *//**
     * Method execute
     * 
     * 
@param mapping
     * 
@param form
     * 
@param request
     * 
@param response
     * 
@return ActionForward
     
*/

    
public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) 
{
        DynaValidatorForm f 
= (DynaValidatorForm) form;
        String username 
= (String) f.get("username");
        String password 
= (String) f.get("password");

        ApplicationContext context 
= new ClassPathXmlApplicationContext(
                
new String[] "applicationContext.xml" });
        userloginDAOimpl getuser 
= (userloginDAOimpl) context.getBean("getUser");
        List list 
= getuser.getUser(username, password);//asm-2.2.3.jar包冲突 自动导包的时候一定要把原包拷贝到目录下 以便删除这个包
        if (!list.isEmpty()) {
            
return mapping.findForward("success");
        }


        
return mapping.findForward("fail");
    }

}
package  cn.userlogin.vo;

/** */ /**
 * Loginuser entity.
 * 
 * 
@author MyEclipse Persistence Tools
 
*/


public   class  Loginuser  implements  java.io.Serializable  {

    
// Fields

    
private String id;
    
private String username;
    
private String password;

    
// Constructors

    
/** *//** default constructor */
    
public Loginuser() {
    }


    
/** *//** full constructor */
    
public Loginuser(String username, String password) {
        
this.username = username;
        
this.password = password;
    }


    
// Property accessors

    
public String getId() {
        
return this.id;
    }


    
public void setId(String id) {
        
this.id = id;
    }


    
public String getUsername() {
        
return this.username;
    }


    
public void setUsername(String username) {
        
this.username = username;
    }


    
public String getPassword() {
        
return this.password;
    }


    
public void setPassword(String password) {
        
this.password = password;
    }


}
<? xml version = " 1.0 "  encoding = " utf-8 " ?>
<! DOCTYPE hibernate - mapping PUBLIC  " -//Hibernate/Hibernate Mapping DTD 3.0//EN "
" http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " >
<!--  
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
< hibernate - mapping >
    
< class  name = " cn.userlogin.vo.Loginuser "  table = " LOGINUSER "  schema = " OLIVER " >
        
< id name = " id "  type = " java.lang.String " >
            
< column name = " ID "   />
            
< generator  class = " native "   />
        
</ id >
        
< property name = " username "  type = " java.lang.String " >
            
< column name = " USERNAME "   />
        
</ property >
        
< property name = " password "  type = " java.lang.String " >
            
< column name = " PASSWORD "   />
        
</ property >
    
</ class >
</ hibernate - mapping >
<? xml version = " 1.0 "  encoding = " UTF-8 " ?>
< beans xmlns = " http://www.springframework.org/schema/beans "
    xmlns:xsi
= " http://www.w3.org/2001/XMLSchema-instance "
    xsi:schemaLocation
= " http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd " >


    
< bean id = " datasource "
        
class = " org.apache.commons.dbcp.BasicDataSource " >
        
< property name = " driverClassName "
            value
= " oracle.jdbc.driver.OracleDriver " >
        
</ property >
        
< property name = " url "
            value
= " jdbc:oracle:thin:@localhost:1521:ora12 " >
        
</ property >
        
< property name = " username "  value = " oliver " ></ property >
        
< property name = " password "  value = " 123 " ></ property >
    
</ bean >
    
< bean id = " sessionFactory "
        
class = " org.springframework.orm.hibernate3.LocalSessionFactoryBean " >
        
< property name = " dataSource " >
            
< ref bean = " datasource "   />
        
</ property >
        
< property name = " hibernateProperties " >
            
< props >
                
< prop key = " hibernate.dialect " >
                    org.hibernate.dialect.Oracle9Dialect
                
</ prop >
            
</ props >
        
</ property >
        
< property name = " mappingResources " >
            
< list >
                
< value > cn / userlogin / vo / Loginuser.hbm.xml </ value ></ list >
        
</ property >
    
</ bean >
    
< bean id = " getUser "   class = " cn.userlogin.dao.impl.userloginDAOimpl " >
     
< property name = " sessionFactory "  ref = " sessionFactory " ></ property >
    
</ bean >
    
</ beans >
<? xml version = " 1.0 "  encoding = " UTF-8 " ?>
<! DOCTYPE struts - config PUBLIC  " -//Apache Software Foundation//DTD Struts Configuration 1.3//EN "   " http://struts.apache.org/dtds/struts-config_1_3.dtd " >

< struts - config >
    
< form - beans >
        
< form - bean name = " userloginForm "
            type
= " org.apache.struts.validator.DynaValidatorForm " >
            
< form - property name = " password "  type = " java.lang.String "   />
            
< form - property name = " username "  type = " java.lang.String "   />
        
</ form - bean >

    
</ form - beans >

    
< global - exceptions  />
    
< global - forwards >
        
< forward name = " success "  path = " /main.jsp "  redirect = " true "   />
        
< forward name = " fail "  path = " /login.jsp "  redirect = " true "   />

    
</ global - forwards >

    
< action - mappings >
        
< action attribute = " userloginForm "  input = " /login.jsp "
            name
= " userloginForm "  parameter = " method "  path = " /userlogin "
            scope
= " request "  validate = " true "
            type
= " cn.userlogin.struts.action.UserloginAction "   />

    
</ action - mappings >
    
< message - resources parameter = " cn.userlogin.struts.ApplicationResources "   />
    
< plug - in className = " org.apache.struts.validator.ValidatorPlugIn " >
        
< set - property property = " pathnames "  value = " /WEB-INF/validator-rules.xml,/WEB-INF/validation.xml "   />
    
</ plug - in >
</ struts - config >
<? xml version = " 1.0 "  encoding = " UTF-8 " ?>
<! DOCTYPE form - validation PUBLIC
          
" -//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.3.0//EN "
          
" http://jakarta.apache.org/commons/dtds/validator_1_3_0.dtd " >
< form - validation >
< formset >
< form name = " userloginForm " >
    
< field property = " username "  depends = " required " >
    
< arg key = " pm.username " />
    
</ field >
    
< field property = " password "  depends = " required " >
    
< arg key = " pm.password " />
    
</ field >
    
</ form >
</ formset >
</ form - validation >
<? xml version = " 1.0 "  encoding = " UTF-8 " ?>
< web - app xmlns = " http://java.sun.com/xml/ns/javaee "  xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
    version
= " 2.5 "
    xsi:schemaLocation
= " http://java.sun.com/xml/ns/javaee   http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd " >
    
< servlet >
        
< servlet - name > action </ servlet - name >
        
< servlet - class > org.apache.struts.action.ActionServlet </ servlet - class >
        
< init - param >
            
< param - name > config </ param - name >
            
< param - value >/ WEB - INF / struts - config.xml </ param - value >
        
</ init - param >
        
< init - param >
            
< param - name > debug </ param - name >
            
< param - value > 3 </ param - value >
        
</ init - param >
        
< init - param >
            
< param - name > detail </ param - name >
            
< param - value > 3 </ param - value >
        
</ init - param >
        
< load - on - startup > 0 </ load - on - startup >
    
</ servlet >
    
< servlet - mapping >
        
< servlet - name > action </ servlet - name >
        
< url - pattern >* . do </ url - pattern >
    
</ servlet - mapping >
    
< welcome - file - list >
        
< welcome - file > index.jsp </ welcome - file >
    
</ welcome - file - list >
</ web - app >

<% @ page language = " java "  pageEncoding = " UTF-8 " %>
<% @ taglib uri = " http://struts.apache.org/tags-html "  prefix = " html " %>
 
< html >  
    
< head >
        
< title > 1111 </ title >
    
</ head >
    
< body >
        
< html:form action = " /userlogin "  method = " post " >
                    用户名: 
< html:text property = " username " />< html:errors property = " username " />< br />
                     密码: 
< html:password property = " password " />< html:errors property = " password " />< br />

            
< html:submit > 提交 </ html:submit >
            
< html:reset > 重置 </ html:reset >
        
</ html:form >
    
</ body >
</ html >

<% @ page language = " java "   import = " java.util.* "  pageEncoding = " ISO-8859-1 " %>
<%
String path 
=  request.getContextPath();
String basePath 
=  request.getScheme() + " :// " + request.getServerName() + " : " + request.getServerPort() + path + " / " ;
%>

<! DOCTYPE HTML PUBLIC  " -//W3C//DTD HTML 4.01 Transitional//EN " >
< html >
  
< head >
    
< base href = " <%=basePath%> " >
    
    
< title > My JSP  ' main.jsp '  starting page </ title >
    
    
< meta http - equiv = " pragma "  content = " no-cache " >
    
< meta http - equiv = " cache-control "  content = " no-cache " >
    
< meta http - equiv = " expires "  content = " 0 " >     
    
< meta http - equiv = " keywords "  content = " keyword1,keyword2,keyword3 " >
    
< meta http - equiv = " description "  content = " This is my page " >
    
<!--
    
< link rel = " stylesheet "  type = " text/css "  href = " styles.css " >
    
-->

  
</ head >
  
  
< body >
    success
!!   < br >
  
</ body >
</ html >
errors.required  =   {0} is  null
pm.username
= User Name
pm.password
= User Password
# Resources 
for  parameter  ' cn.userlogin.struts.ApplicationResources '
# Project userlogin
errors.required  =   {0} \u4E0D\u80FD\u4E3A\u7A7A
pm.username
= \u7528\u6237\u540D
pm.password
= \u5BC6\u7801
# Resources 
for  parameter  ' cn.userlogin.struts.ApplicationResources '
# Project userlogin