• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > 编程与数据库 > Jsp编程 >

Spring+Struts2整合(2)

来源: www.dedecms8.com 编辑:织梦吧 时间:2012-06-29点击:

    public String execute(){ 
         
        if(loginDao.login(username, password)){ 
            return "success"; 
        }else{ 
            return "input"; 
        } 
    } 
 
    public String getUsername() { 
        return username; 
    } 
 
    public void setUsername(String username) { 
        this.username = username; 
    } 
 
    public String getPassword() { 
        return password; 
    } 
 
    public void setPassword(String password) { 
        this.password = password; 
    } 
 
    public LoginDao getLoginDao() { 
        return loginDao; 
    } 
 
    public void setLoginDao(LoginDao loginDao) { 
        this.loginDao = loginDao; 
    } 
     

struts.xml配置文件

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
    "http://struts.apache.org/dtds/struts-2.0.dtd"> 
 
<struts> 
 
    <package name="default" namespace="/" extends="struts-default"> 
        <action name="login" class="com.itmyhome.actioin.LoginAction"> 
           <result name="success">/success.jsp</result> 
           <result name="input">/login.jsp</result> 
        </action> 
    </package> 
 
    <!-- Add packages here --> 
 
</struts> 

applicationContext.xml配置文件

<bean id="loginDao" class="com.itmyhome.actioin.LoginDaoImpl" /> 
 
<!-- 可注释  --> 
<bean id="loginAction" class="com.itmyhome.actioin.LoginAction"> 
    <property name="loginDao" ref="loginDao" /> 
</bean> 

部署,启动tomcat 输入"zhangsan","123" 跳转到success.jsp 整合成功

摘自 itmyhome的专栏

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ