Browse Source

修复中文解码问题

刘韬 6 years ago
parent
commit
7b891e7782

+ 13 - 2
PacsOnline_Wechat_Patient/src/main/java/com/zskk/controller/WeixinApiController.java

@@ -1,5 +1,8 @@
 package com.zskk.controller;
 package com.zskk.controller;
 
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
 import com.jfinal.kit.PropKit;
 import com.jfinal.kit.PropKit;
 import com.jfinal.weixin.sdk.api.AccessTokenApi;
 import com.jfinal.weixin.sdk.api.AccessTokenApi;
 import com.jfinal.weixin.sdk.api.ApiConfigKit;
 import com.jfinal.weixin.sdk.api.ApiConfigKit;
@@ -122,7 +125,14 @@ public class WeixinApiController extends ApiController {
         String source = getPara("source");
         String source = getPara("source");
         String content = getPara("content");
         String content = getPara("content");
 		String appId;
 		String appId;
-        switch (source) {
+		String source_utf8 = null;
+		try {
+			source_utf8 = URLDecoder.decode(source, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        switch (source_utf8) {
 		case "中世康恺电子胶片平台":
 		case "中世康恺电子胶片平台":
 			appId = PropKit.get("appId_zskk");
 			appId = PropKit.get("appId_zskk");
 			break;
 			break;
@@ -143,9 +153,10 @@ public class WeixinApiController extends ApiController {
 			appId = PropKit.get("appId_zskk");
 			appId = PropKit.get("appId_zskk");
 			break;
 			break;
 		}
 		}
+        
         ApiConfigKit.setThreadLocalAppId(appId);
         ApiConfigKit.setThreadLocalAppId(appId);
 		WeixinService wService = ServiceFactory.getService(WeixinService.class);
 		WeixinService wService = ServiceFactory.getService(WeixinService.class);
-		ApiResult apiResult = wService.sendTemplateMsg(openid, content, pushType, source);
+		ApiResult apiResult = wService.sendTemplateMsg(openid, content, pushType, source_utf8);
 		renderJson(apiResult);
 		renderJson(apiResult);
     }
     }