struts2國際化問題

2021-05-26 02:50:52 字數 460 閱讀 1315

工程圖如下所示:

問題原因:沒有用action跳轉到jsp頁,而是通過直接訪問jsp的原因。網上這麼說的:直接訪問jsp,struts 2.0在web.xml的配置的過濾器(filter)就不會工作,所以***鏈也不會工作。

struts2國際化的步驟: 

1、判斷struts.locale屬性(在struts.properties)是否有值,如果有值,將這個值轉換為locale物件儲存到actioncontext中。 

2、如果沒有設定struts.locale,從瀏覽器傳送的請求報頭里獲得語言資訊,建立locale物件,儲存到actioncontext中。 

3、i18ninterceptor***獲取名為request_locale請求引數的值,如果這個值存在則建立以這個值的locale物件,然後將這個物件作為session的屬性(ww_trans_i18n_locale)儲存,並儲存到actioncontext中。 

Struts2的國際化

1.在struts.xml中新增 2.在src根檔案中新建file檔案命名為message zh.properties這是漢語 message en.properties 這是英語的。這裡的值是成鍵值對出現的。3.在jsp檔案中則可以實現其國際化在如使用者名稱則可以寫成如果是submit則 如果不在...

Struts2的國際化

struts2國際化分為三類 全域性的,包級別的,類級別的。全域性的 1 在struts.xml中的指定basename 國際化檔名為 basename 語言名 國家名.properties 如 message zh cn.properties 2 全域性的國際化資源檔案放在src下面。包級別的 1...

struts2的國際化

首先把struts框架搭建成功,然後在src下建立資源檔案,資源檔案命名可以是如下三種形式 basename language country.properties basename language.properties basename.properties basename可自定義,語言編碼和...