国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Struts的常量與全局配置

2019-11-06 06:37:21
字體:
來源:轉載
供稿:網友

Struts常量

Struts中默認訪問后綴:

Struts1中默認訪問后綴是*.do

Struts2中默認訪問后綴是*.action

 

如何修改默認訪問后綴

1、Struts2的.action訪問后綴在哪里定義?

Struts-core-2.3.4-1.jar/org.apache.struts/default.PRopertles

Struts.action.extendsion=action..

2、在struts.xml中通過常量修改

<constant name=”struts.action.extension” value=”action,do,”></constant>

指定訪問后綴為action/do/沒有訪問后綴都可以

 

Value=”action,do,”    訪問后綴:action/do/不帶后綴

Value=”action,do”   訪問后綴:action或do

Value=”action” 訪問后最:action

 

 

常量:

   a、 指定默認編碼集,作用于HttpServletRequest的setCharacterEncoding方法 和freemarker 、velocity的輸出(post有效)

<constant name="struts.i18n.encoding" value="UTF-8"/>

 

    b、自定義后綴修改常量

<constant name="struts.action.extension" value="do"/>

 

    c、設置瀏覽器是否緩存靜態內容,默認值為true(生產環境下使用),開發階段最好關閉

<constant name="struts.serve.static.browserCache" value="false"/>

 

    d、當struts的配置文件修改后,系統是否自動重新加載該文件,默認值為false(生產環境下使用),開發階段最好打開

<constant name="struts.configuration.xml.reload" value="true"/>

 

    e、開發模式下使用,這樣可以打印出更詳細的錯誤信息

<constant name="struts.devMode" value="true" />

 

 

    f、默認的視圖主題

<constant name="struts.ui.theme" value="simple" />

 

    g、與spring集成時,指定由spring負責action對象的創建

<constant name="struts.objectFactory" value="spring" />

 

 

    h、該屬性設置Struts 2是否支持動態方法調用,該屬性的默認值是true。如果需要關閉動態方法調用,則可設置該屬性為false

<constant name="struts.enable.DynamicMethodInvocation" value="true"/>

作用:

當我們配置**.xml文件的action時,可以不配置method,可以直接通過訪問地址訪問指定的method

如:

我問需要訪問hello-->login()

方法一:配置method

http://localhost:8080/StrutStu/hello

方法二:通過動態方法訪問

http://localhost:8080/StrutStu/hello!login

 

    i、上傳文件的大小限制

<constant name="struts.multipart.maxSize" value=“10701096"/>

 

 

配置全局跳轉視圖

<!--  配置全局跳轉視圖  -->		<global-results>			<result name="login">/success.jsp</result>		</global-results>		<action name="hello" class="cn.lfsenior.c_config.HelloWord" method="login" >			<!-- 返回結果標記login對應的頁面在當前action中沒有配置				 所以會去找全局配置是否有login標記對應的頁面			 -->		</action>

配置各項默認值

<!-- 配置各項默認值 -->		 <!-- 		 	 name  只配置了訪問路徑名稱		 	 class 默認執行的action在struts-default有配置		 	 		<default-class-ref class="com.opensymphony.xwork2.ActionSupport" />		 	 method  默認為execute		 	 默認的方法execute返回值為success,對應的頁面去全局視圖找。		 	 		  -->		 <action name="test"></action>				<!-- 什么情況不配置class? 即處理的aciton -->		<!-- 答案: 當只是需要跳轉到WEB-INF下資源的時候。(WEB-INF下的資源只對服務端開發,不對客戶端開發。所以只能通過轉發訪問,不能通過重定向訪問) -->		 <action name="test2">		 	<result name="success" type="redirect">/WEB-INF/index.jsp</result>		 </action>

 

 

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泾川县| 福建省| 苏尼特右旗| 泊头市| 朔州市| 东丽区| 黄冈市| 正镶白旗| 从江县| 宝清县| 武夷山市| 宜丰县| 馆陶县| 九龙坡区| 沙坪坝区| 扬中市| 墨玉县| 清涧县| 新沂市| 遵义市| 互助| 肥城市| 阿克陶县| 屏南县| 大丰市| 托克托县| 惠东县| 浏阳市| 兰溪市| 博野县| 巧家县| 济阳县| 北川| 广安市| 新化县| 石楼县| 瑞金市| 公主岭市| 靖远县| 虎林市| 克拉玛依市|