- 先確認eclipse的編碼
- 確認project中檔案的編碼
- 確認 hibernate 的編碼
如果是因為這個原因,直接直接在jdbc的dabase url 上註明其編碼<property name="hibernate.connection.url" value="utf8" >jdbc:mysql://127.0.0.1/MyTable?characterEncoding=utf8</property>
- 修改
Project Folder/src/main/webapp/WEB-INF/web.xml
,於web-app tag中加入下方code<filter> <filter-name>setCharacterEncoding</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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>setCharacterEncoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
參考資料
Hibernate character encoding, postgresql. (2010, 9 7). Retrieved from https://forum.hibernate.org/viewtopic.php?f=1&t=1006879
沒有留言:
張貼留言