struts环境怎么搭建_用idea搭建struts2.5教程。
一.STRUTS介紹
二.搭建環境(使用INTELLIJ IDEA+MAVEN+STRUTS2)
1.建立MAVEN+STRUTS2項目
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
啟動成功
訪問成功