SpringMVC配置解決中文亂碼的過濾器

2021-10-06 19:53:09 字數 793 閱讀 8497

jsp中有乙個表單,輸入屬性,後台接收到後會在控制台輸出。但是如果tomcat版本比較低,表單中有中文的話輸出會亂碼,解決這個問題需要配置解決中文亂碼的過濾器。

!--配置解決中文亂碼的過濾器--

>

characterencodingfilter<

/filter-name>

class

>org.springframework.web.filter.characterencodingfilter<

/filter-

class

>

encoding<

/param-name>

utf-

8<

/param-value>

<

/init-param>

<

/filter>

characterencodingfilter<

/filter-name>

/<

/url-pattern>

<

寫好過濾器後,重新啟動伺服器,結果如圖,就不會有亂碼了。

SpringMVC解決中文亂碼

springmvc可以在web.xml中通過配置characterencodingfilter過濾器來解決post請求中的中文亂碼,同時我們也要保證jsp頁面也是utf 8標準。在tomcat8及以後會自動解決get請求的亂碼,如果不是8及以後我們也可以手動配置解決 1.post亂碼通過過濾器解決 ...

springMVC解決中文亂碼問題

1.post請求亂碼問題 在web.xml中加入 filter filter name characterencodingfilter filter name filter class org.springframework.web.filter.characterencodingfilter fi...

springmvc 解決中文亂碼 2

表單提交的方式是post,那麼如何來解決post提交的中文亂碼問題呢?我們可在web.xml檔案中加入乙個過濾器,如下 characterencodingfilter org.springframework.web.filter.characterencodingfilter encoding ut...