频道栏目
首页 > 资讯 > 其他 > 正文

struts环境怎么搭建_用idea搭建struts2.5教程

17-09-27        来源:[db:作者]  
收藏   我要投稿

struts环境怎么搭建_用idea搭建struts2.5教程。

一.STRUTS介紹

二.搭建環境(使用INTELLIJ IDEA+MAVEN+STRUTS2)

1.建立MAVEN+STRUTS2項目
1).建立Maven項目:maven快速入門

2).設置Groupld和Artfactld名稱
2.添加配置檔案,自動下載必要JAR包
commons-fileupload-1.2.2.jar 【檔案上傳相關包】
commons-io-2.0.1.jar
struts2-core-2.3.4.1.jar 【struts2核心功能包】
ognl-3.0.5.jar 【Ognl表達式功能支援表】
commons-lang3-3.1.jar 【struts對java.lang包的擴展】
freemarker-2.3.19.jar 【struts的標籤模板庫jar檔案】
javassist-3.11.0.GA.jar 【struts對位元組碼的處理相關jar】
配置檔案引入


    org.apache.struts
    struts2-core
    2.5.10.1

这里写图片描述

3.WEB.XML中引入STRUTS核心功能——配置過濾器


  Archetype Created Web Application
  
  
    struts2
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
  
  
    struts2
    /*
  
  
    index.jsp
  

这里写图片描述
4.開發ACTION
LoginAction.java

package com.huan.struts.action;

/**
 * Created by 馬歡歡 on 2017/6/19.
 */
public class LoginAction {
    public String success(){
        System.out.println("成功訪問action,請求正在處理中");
        System.out.println("調用service");
        return "success";
    }
}

success.jsp

<%--
  Created by IntelliJ IDEA.
  User: 馬歡歡
  Date: 2017/6/19
  Time: 21:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

5.配置ACTION——SRC/STRUTS.XML

struts2.xml






    
        
            success.jsp
        
    

1.建立MAVEN+STRUTS2項目步驟:

1).建立Maven項目:maven快速入門

2).設置Groupld和Artfactld名稱
这里写图片描述

2.添加配置檔案,自動下載必要JAR包

commons-fileupload-1.2.2.jar 【檔案上傳相關包】
commons-io-2.0.1.jar
struts2-core-2.3.4.1.jar 【struts2核心功能包】
ognl-3.0.5.jar 【Ognl表達式功能支援表】
commons-lang3-3.1.jar 【struts對java.lang包的擴展】
freemarker-2.3.19.jar 【struts的標籤模板庫jar檔案】
javassist-3.11.0.GA.jar 【struts對位元組碼的處理相關jar】
配置檔案引入
pom.xml


    org.apache.struts
    struts2-core
    2.5.10.1

3.webxml中引入struts核心功能——配置過濾器

web.xml


  Archetype Created Web Application
  
  
    struts2
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
  
  
    struts2
    /*
  
  
    index.jsp
  

4.開發ACTION
LoginAction.java


package com.huan.struts.action;

/**
 * Created by 馬歡歡 on 2017/6/19.
 */
public class LoginAction {
    public String success(){
        System.out.println("成功訪問action,請求正在處理中");
        System.out.println("調用service");
        return "success";
    }
}

success.jsp

<%--
  Created by IntelliJ IDEA.
  User: 馬歡歡
  Date: 2017/6/19
  Time: 21:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

5.配置ACTION——SRC/STRUTS.XML

struts2.xml






    
        
            success.jsp
        
    

这里写图片描述

这里写图片描述
啟動成功
訪問成功
这里写图片描述

相关TAG标签
上一篇:Could not find com.android.support:support-v4:26.0.2
下一篇:react-store工作流程
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站