解決struts2以GET方式提交表單中文亂碼問題

2021-08-08 12:20:29 字數 1356 閱讀 5284

原創2023年11月29日 17:25:22

之前用post方式提交表單一直沒有遇到中文亂碼的方式,最近使用get方式提交,發現中文亂碼。 檢測了struts.xml和web.xml等地方讀配置好了

struts.xml

[html]

view plain

copy

<

constant

name

="struts.i18n.encoding"

value

="utf-8"

/>

web.xml

[html]

view plain

copy

<

filter

>

<

filter-name

>

encodingfilter

filter-name

>

<

filter-class

>

org.springframework.web.filter.characterencodingfilter

filter-class

>

<

init-param

>

<

param-name

>

encoding

param-name

>

<

param-value

>

utf-8

param-value

>

init-param

>

filter

>

<

>

<

filter-name

>

encodingfilter

filter-name

>

<

url-pattern

>

/*url-pattern

>

>

查了一些資料,問題出在於tomcat的server.xml沒有配置編碼,新增uriencoding="utf-8"就可以了

舉報

Struts2取值方式

通過取值 2.標籤取值方式二 在頁面中可以這樣獲取 或者直接這樣用 userbean可以是request或session中的物件。struts2中的action 中的內容為 actioncontext ctx actioncontext.getcontext ctx.getsession.put c...

Struts2標籤取值方式

1.標籤取值方式一 通過取值 2.標籤取值方式二 在頁面中可以這樣獲取 或者直接這樣用 userbean可以是request或session中的物件。struts2中的action 中的內容為 actioncontext ctx actioncontext.getcontext ctx.getses...

Struts2標籤取值方式

2011 05 26 13 10 31 分類 struts2 舉報 字型大小訂閱 1.標籤取值方式一 通過取值 2.標籤取值方式二 在頁面中可以這樣獲取 或者直接這樣用 userbean可以是request或session中的物件。struts2中的action 中的內容為 actioncontex...