在 IDEA 中配置 Struts2
利用 IDEA 中的 maven 專案整合簡單的 Struts2 (在此記錄一下,方便以後查詢)
- 在 maven 中新增依賴:
<!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.16</version>
</dependency>
- 在 resources 資料夾下面建立
struts.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<!-- 指定struts2是否以開發模式執行
1.熱載入主配置.(不需要重啟即可生效)
2.提供更多錯誤資訊輸出,方便開發時的除錯
-->
<constant name="struts.devMode" value="true"/>
<!-- 指定訪問 action 時的字尾名 -->
<constant name="struts.action.extension" value="action,,"/>
<!-- extends:必填 -->
<package name="result" namespace="/result" extends="struts-default">
<action name="resultAction" class="mm.web.learn.struts2._00ResultAction" method="execute">
<!--
type:預設是轉發
-->
<result name="success" type="dispatcher">/hello.jsp</result>
</action>
</package>
<!-- 引入其他配置 其他配置也必須放在 resources 資料夾下面-->
<include file="/struts_dynamic.xml"/>
</struts>
- 建立類
mm.web.learn.struts2._00ResultAction
package mm.web.learn.struts2;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
public class _00ResultAction extends ActionSupport {
public String execute() throws Exception {
return Action.SUCCESS;
}
}
- 啟動專案,訪問
http://localhost:8080/result/resultAction
相關文章
- 在Intellij IDEA中如何配置MavenIntelliJIdeaMaven
- IDEA中Maven的配置IdeaMaven
- struts2中的6大配置檔案
- Struts2中 Result型別配置詳解型別
- 在IDEA裡gradle配置和使用IdeaGradle
- IDEA中配置Git,在Github上clone專案到IDEAIdeaGithub
- struts2配置中的method{數字}屬性
- 在Struts2中寫介面,返回json格式JSON
- Struts2配置後ClassNotFoundExceptionException
- 在idea中手動安裝lombokIdeaLombok
- Struts2 配置檔案(八)
- Struts2 XML配置詳解XML
- idea 配置sftpIdeaFTP
- idea配置mavenIdeaMaven
- 安裝maven,並將其配置到idea中MavenIdea
- 【Struts2複習知識點一】-配置struts2環境
- 在struts2中實現去掉字尾及url重寫
- 一個請求在Struts2框架中的處理流程框架
- 2020年:maven配置最新阿里雲映象,以及在IDEA中的設定Maven阿里Idea
- Struts2在web.xml中配置為“/*”和“*.action,*.jsp”的差別WebXMLJS
- struts2中session使用Session
- Idea Project Structure配置IdeaProjectStruct
- [idea中配置maven]IdeaMaven
- 配置IDEA和STRUTSIdea
- Struts2 OGNL動態配置result(十八)
- JFreeChart在Struts2中折線圖統計的實現
- 在eclipse中maven配置EclipseMaven
- 在 Intellij IDEA 中的 Debug 使用詳解IntelliJIdea
- 使用Cloud Toolkit在IDEA中極速建立dubbo工程CloudIdea
- 在IDEA中通過Module管理多個專案Idea
- 在idea中利用spingboot建立maven專案IdeabootMaven
- IntelliJ IDEA 配置代理IntelliJIdea
- idea怎麼配置mongodbIdeaMongoDB
- Intellij idea 配置JDKIntelliJIdeaJDK
- Intellij IDEA配置JDKIntelliJIdeaJDK
- Require.js中的路徑在IDEA中的最佳實踐UIJSIdea
- 在Struts2中ValueStack、ActionContext、ServletContext、request、session關係分析ContextServletSession
- 在struts2框架中實現手動處理輸入驗證框架