struts2(基礎)--struts.xml配置文件詳解

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
	"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
	"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	
	<!-- i18n:國際化. 解決post提交亂碼 -->
	<constant name="struts.i18n.encoding" value="UTF-8"></constant>
	<!-- 指定訪問action時的後綴名 
		http://localhost:8080/Struts2/hello/HelloAction.do
	-->
	<constant name="struts.action.extension" value="action"></constant>
	<!-- 指定struts2是否以開發模式運行
			1.熱加載主配置.(不需要重啓即可生效)
			2.提供更多錯誤信息輸出,方便開發時的調試
	 -->
	<constant name="struts.devMode" value="true"></constant>
	
	

	<!-- package:將Action配置封裝.就是可以在Package中配置很多action.
			name屬性: 給包起個名字,起到標識作用.隨便起.不能其他包名重複.
			namespace屬性:給action的訪問路徑中定義一個命名空間
			extends屬性: 繼承一個 指定包
			abstract屬性:包是否爲抽象的; 標識性屬性.標識該包不能獨立運行.專門被繼承
	  -->
	<package name="hello" namespace="/hello" extends="struts-default" >
		<!-- action元素:配置action類
				name屬性: 決定了Action訪問資源名.
				class屬性: action的完整類名
				method屬性: 指定調用Action中的哪個方法(配置方法)來處理請求
		 -->
		<action name="HelloAction" class="cn.huyouni.HelloAction" method="fun1" >
			<!-- result元素:結果配置 
					name屬性: 標識結果處理的名稱.與action方法的返回值對應.
					type屬性: 指定調用哪一個result類來處理結果,默認使用轉發.
					標籤體:填寫頁面的相對路徑
			-->
			<result name="success" type="dispatcher" >/hello.jsp</result>
		</action>
	</package>
	<!-- 引入其他struts配置文件 -->
	<include file="com/huyouni/struts.xml"></include>
</struts>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章