国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
修改struts2 顯示的URL 后綴 為.action 為 .jsp
  正在用 SSH(struts2.0+spring3.0+hibernate2.0)開發(fā)一個(gè)項(xiàng)目,但是struts2.0 請(qǐng)求action 后轉(zhuǎn)到的頁面的后綴都成了XXX_XXXX.action (我用的通配符設(shè)置的action).看著很是不習(xí)慣,需要修改!??!

     (前臺(tái)的頁面顯示需要數(shù)據(jù)庫中的數(shù)據(jù),所以顯示之前必須訪問數(shù)據(jù)庫??!)

 

解決方案:

  1,開始想用Ajax技術(shù)。來取得數(shù)據(jù)庫的數(shù)據(jù)。但一旦數(shù)據(jù)量過大或過于凌亂,則是個(gè)大問題!

 

  2,由于struts2.0 訪問數(shù)據(jù)庫之后,頁面顯示的url 都是訪問的action 的名字?,F(xiàn)在考慮修改struts2.0的攔截器的攔截后綴。(默認(rèn)為.action,現(xiàn)想修改為.jsp)如此以來,則前臺(tái)的URL 就不會(huì)出現(xiàn)XXX_XXXX.action ,而是XXX.jsp.

  

 查閱資料:得到:  可以在 struts.xml  配置文件中 修改 攔截器的攔截屬性:

            修改struts.xml文件,在<struts></struts>中加入下面這句話。

Xml代碼
  1. <constant name="struts.action.extension" value="action,jsp" />   
  1. <constant name="struts.action.extension" value="action,jsp" />   

 

如此以來,strtus2.0 就開始 攔截 后綴為 .action 和 .jsp 的請(qǐng)求。

 

例:如果訪問的頁面為 index.jsp

  struts.xml  代碼為

Java代碼
  1. <?xml version="1.0" encoding="UTF-8"?>   
  2. <!DOCTYPE struts PUBLIC   
  3.         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.         "http://struts.apache.org/dtds/struts-2.0.dtd">   
  5. <struts>   
  6.     <!-- 程序國際化 指定國際化資源文件 -->   
  7.     <constant name="struts.custom.i18n.resources"  
  8.         value="ApplicationResources" />   
  9.     <constant name="struts.i18n.encoding" value="gb2312" />   
  10.     <constant name="struts.i18n.reload" value="false"></constant>   
  11.     <constant name="struts.action.extension" value="action,jsp" />   
  12.     <!-- 設(shè)置上傳文件時(shí)不要Tomcat的臨時(shí)路徑,使用設(shè)置的值 -->   
  13.     <constant name="struts.multipart.saveDir" value="/temp" />   
  14.     <!-- 設(shè)置上傳文件大小 -->   
  15.     <constant name="struts.multipart.maxSize" value="524280" />   
  16.     <package name="outlook" extends="struts-default">   
  17.         <global-results>   
  18.             <!-- 下面定義的結(jié)果對(duì)所有的Action都有效 -->   
  19.             <result name="exception">/error.jsp</result>   
  20.         </global-results>   
  21.         <global-exception-mappings>   
  22.             <!-- 指Action拋出Exception異常時(shí),轉(zhuǎn)入名為exception的結(jié)果。 -->   
  23.             <exception-mapping exception="java.lang.Exception"  
  24.                 result="exception" />   
  25.         </global-exception-mappings>   
  26.     </package>   
  27.     <!-- 網(wǎng)站后臺(tái)配置 -->   
  28.     <package name="Outlook" extends="struts-default" namespace="/">   
  29.         <interceptors>   
  30.             <!-- 定義了一個(gè)名為authority的攔截器 -->   
  31.             <interceptor name="authority"  
  32.                 class="org.boss.action.AuthorityInterceptor">   
  33.             </interceptor>   
  34.         </interceptors>   
  35.         <!-- 定義全局Results -->   
  36.         <global-results>   
  37.             <result name="success">/barhome/success.jsp</result>   
  38.             <result name="none">/barhome/doerror.jsp</result>   
  39.             <result name="exception">/barhome/error.jsp</result>   
  40.         </global-results>   
  41.         <global-exception-mappings>   
  42.             <!-- 指Action拋出Exception異常時(shí),轉(zhuǎn)入名為exception的結(jié)果。 -->   
  43.             <exception-mapping exception="java.lang.Exception"  
  44.                 result="exception" />   
  45.         </global-exception-mappings>   
  46.         <action name="index" class="org.boss.action.OutLookAction">   
  47.             <result name="goindex">/home.jsp</result>   
  48.         </action>   
  49.     </package>   
  50. </struts>  
  1. <?xml version="1.0" encoding="UTF-8"?>   
  2. <!DOCTYPE struts PUBLIC   
  3.         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.         "http://struts.apache.org/dtds/struts-2.0.dtd">   
  5. <struts>   
  6.     <!-- 程序國際化 指定國際化資源文件 -->   
  7.     <constant name="struts.custom.i18n.resources"  
  8.         value="ApplicationResources" />   
  9.     <constant name="struts.i18n.encoding" value="gb2312" />   
  10.     <constant name="struts.i18n.reload" value="false"></constant>   
  11.     <constant name="struts.action.extension" value="action,jsp" />   
  12.     <!-- 設(shè)置上傳文件時(shí)不要Tomcat的臨時(shí)路徑,使用設(shè)置的值 -->   
  13.     <constant name="struts.multipart.saveDir" value="/temp" />   
  14.     <!-- 設(shè)置上傳文件大小 -->   
  15.     <constant name="struts.multipart.maxSize" value="524280" />   
  16.     <package name="outlook" extends="struts-default">   
  17.         <global-results>   
  18.             <!-- 下面定義的結(jié)果對(duì)所有的Action都有效 -->   
  19.             <result name="exception">/error.jsp</result>   
  20.         </global-results>   
  21.         <global-exception-mappings>   
  22.             <!-- 指Action拋出Exception異常時(shí),轉(zhuǎn)入名為exception的結(jié)果。 -->   
  23.             <exception-mapping exception="java.lang.Exception"  
  24.                 result="exception" />   
  25.         </global-exception-mappings>   
  26.     </package>   
  27.     <!-- 網(wǎng)站后臺(tái)配置 -->   
  28.     <package name="Outlook" extends="struts-default" namespace="/">   
  29.         <interceptors>   
  30.             <!-- 定義了一個(gè)名為authority的攔截器 -->   
  31.             <interceptor name="authority"  
  32.                 class="org.boss.action.AuthorityInterceptor">   
  33.             </interceptor>   
  34.         </interceptors>   
  35.         <!-- 定義全局Results -->   
  36.         <global-results>   
  37.             <result name="success">/barhome/success.jsp</result>   
  38.             <result name="none">/barhome/doerror.jsp</result>   
  39.             <result name="exception">/barhome/error.jsp</result>   
  40.         </global-results>   
  41.         <global-exception-mappings>   
  42.             <!-- 指Action拋出Exception異常時(shí),轉(zhuǎn)入名為exception的結(jié)果。 -->   
  43.             <exception-mapping exception="java.lang.Exception"  
  44.                 result="exception" />   
  45.         </global-exception-mappings>   
  46.         <action name="index" class="org.boss.action.OutLookAction">   
  47.             <result name="goindex">/home.jsp</result>   
  48.         </action>   
  49.     </package>   
  50. </struts>  

 

action 的代碼

Java代碼
  1. public String execute()throws Exception{   
  2.         this.getChannel();// 網(wǎng)站頻道信息   
  3.            
  4.         return "goindex";   
  5.     }  
  1. public String execute()throws Exception{   
  2.         this.getChannel();// 網(wǎng)站頻道信息   
  3.            
  4.         return "goindex";   
  5.     }  

 

OK ,問題解決??!現(xiàn)在URL的顯示正常了。??!

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Struts2全局跳轉(zhuǎn)與局部跳轉(zhuǎn)
struts2:struts.xml配置文件詳解
struts 2 學(xué)習(xí)相關(guān)1
Struts2中使用token避免重復(fù)提交的方法
Strtus2 Convention Plugin 配置規(guī)則
使用struts2.5版本遇到的問題
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服