解決SpringMVC的GET請求中文亂碼
阿新 • • 發佈:2018-11-24
進行轉碼
@RequestMapping("querySupplyToJSON") @ResponseBody public List<Supply> querySupplyByJson(Supply supply) throws UnsupportedEncodingException{ String str = new String(supply.getGongyingshangname1().getBytes("ISO-8859-1"), "utf-8"); System.out.println("====="+supply.getGongyingshangname1()+"===="+str); return supplyService.queryAll(); }
控制檯的結果,轉碼前和轉碼後的結果
[DEBUG] 2018-09-15 16:42:05,261 org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'supplyController'
[DEBUG] 2018-09-15 16:42:05,261 org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/bookTest/querySupplyToJSON] is: -1
=====é??====陝
[DEBUG] 2018-09-15 16:42:05,289 org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession