flowable-ui-idm,task,modeler 三個模塊可以正常顯示中文,但是flowable-ui-admin中文不能正常顯示(flowable6.1.2以下版本包括該版本),比如我們定義了流程之后,顯示查詢之后,如下圖所示:
下面,我們看一下這個bug出現(xiàn)的原因。首先我們看一下上傳文檔對應的實現(xiàn),該服務功能位于DeploymentCollectionResource類中的uploadDeployment方法中,實例代碼如下:
public DeploymentResponse uploadDeployment(@ApiParam(name = "deploymentKey") @RequestParam(value = "deploymentKey", required = false) String deploymentKey,
@ApiParam(name = "deploymentName") @RequestParam(value = "deploymentName", required = false) String deploymentName,
@ApiParam(name = "tenantId") @RequestParam(value = "tenantId", required = false) String tenantId,
HttpServletRequest request, HttpServletResponse response) {
......
if (StringUtils.isEmpty(deploymentName)) {
}
看到上述的代碼StringUtils.isEmpty(deploymentName)就明白了,原來這個地方并沒有進行編碼工作,中文當然要亂碼了,正確的寫法,應該是對所有的參數(shù)進行解碼,類似下面的代碼:
URLDecoder.decode(string, "UTF-8")
如果這個問題,讓我們自己解決可能有點麻煩,所以直接反饋給flowable官方了,目前官方已經(jīng)修復了該bug。如下所示:
.../src/main/java/org/flowable/rest/service/api/repository/DeploymentCollectionResource.java
@@ -13,6 +13,8 @@
packageorg.flowable.rest.service.api.repository;
+importjava.io.UnsupportedEncodingException;
+importjava.net.URLDecoder;
importjava.util.HashMap;
importjava.util.Map;
importjava.util.zip.ZipInputStream;
@@ -143,6 +145,9 @@ public DeploymentResponse uploadDeployment(@ApiParam(name = "deploymentKey") @Re
thrownewFlowableIllegalArgumentException("Multipart request is required");
}
+StringqueryString=request.getQueryString();
+MapdecodedQueryStrings=splitQueryString(queryString);
+
MultipartHttpServletRequestmultipartRequest=(MultipartHttpServletRequest) request;
if(multipartRequest.getFileMap().size()==0) {
@@ -167,7 +172,7 @@ public DeploymentResponse uploadDeployment(@ApiParam(name = "deploymentKey") @Re
thrownewFlowableIllegalArgumentException("File must be of type .bpmn20.xml, .bpmn, .bar or .zip");
}
-if(StringUtils.isEmpty(deploymentName)) {
+if(!decodedQueryStrings.containsKey("deploymentName")||StringUtils.isEmpty(decodedQueryStrings.get("deploymentName"))) {
StringfileNameWithoutExtension=fileName.split("\\.")[0];
if(StringUtils.isNotEmpty(fileNameWithoutExtension)) {
@@ -176,11 +181,11 @@ public DeploymentResponse uploadDeployment(@ApiParam(name = "deploymentKey") @Re
deploymentBuilder.name(fileName);
}else{
- ? ? ? ? ? ? ? ?deploymentBuilder.name(deploymentName);
+ ? ? ? ? ? ? ? ?deploymentBuilder.name(decodedQueryStrings.get("deploymentName"));
}
-if(deploymentKey!=null) {
- ? ? ? ? ? ? ? ?deploymentBuilder.key(deploymentKey);
+if(decodedQueryStrings.containsKey("deploymentKey")||StringUtils.isNotEmpty(decodedQueryStrings.get("deploymentKey"))) {
+ ? ? ? ? ? ? ? ?deploymentBuilder.key(decodedQueryStrings.get("deploymentKey"));
}
if(tenantId!=null) {
@@ -200,4 +205,23 @@ public DeploymentResponse uploadDeployment(@ApiParam(name = "deploymentKey") @Re
thrownewFlowableException(e.getMessage(), e);
}
}
+
+publicMapsplitQueryString(StringqueryString) {
+MapqueryMap=newHashMap<>();
+for(Stringparam:queryString.split("&")) {
+ ? ? ? ? ? ?queryMap.put(StringUtils.substringBefore(param,"="), decode(StringUtils.substringAfter(param,"=")));
+ ? ? ? ?}
+returnqueryMap;
+ ? ?}
+
+protectedStringdecode(Stringstring) {
+if(string!=null) {
+try{
+returnURLDecoder.decode(string,"UTF-8");
+ ? ? ? ? ? ?}catch(UnsupportedEncodingExceptionuee) {
+thrownewIllegalStateException("JVM does not support UTF-8 encoding.", uee);
+ ? ? ? ? ? ?}
+ ? ? ? ?}
+returnnull;
+ ? ?}
}
2modules/flowable-ui-admin/src/main/webapp/scripts/app.js
@@ -208,7 +208,7 @@ flowableAdminApp
//.registerAvailableLanguageKeys(['en'], {
//'en-*': 'en'
//})
- ? ? ? ? ? ?.useSanitizeValueStrategy('sanitizeParameters')
+ ? ? ? ? ? ?.useSanitizeValueStrategy('escapeParameters')
.uniformLanguageTag('bcp47')
.determinePreferredLanguage();
2modules/flowable-ui-idm/flowable-ui-idm-app/src/main/webapp/scripts/idm-app.js
@@ -126,7 +126,7 @@ flowableApp
//.registerAvailableLanguageKeys(['en'], {
//'en-*': 'en'
//})
- ? ? ? ?.useSanitizeValueStrategy('sanitizeParameters')
+ ? ? ? ?.useSanitizeValueStrategy('escapeParameters')
.uniformLanguageTag('bcp47')
.determinePreferredLanguage();
}])
2modules/flowable-ui-modeler/flowable-ui-modeler-app/src/main/webapp/scripts/app.js
@@ -140,7 +140,7 @@ flowableModeler
//.registerAvailableLanguageKeys(['en'], {
//'en-*': 'en'
//})
- ? ? ? ?.useSanitizeValueStrategy('sanitizeParameters')
+ ? ? ? ?.useSanitizeValueStrategy('escapeParameters')
.uniformLanguageTag('bcp47')
.determinePreferredLanguage();
2modules/flowable-ui-task/flowable-ui-task-app/src/main/webapp/scripts/landing-app.js
@@ -66,7 +66,7 @@ flowableApp
//.registerAvailableLanguageKeys(['en'], {
//'en-*': 'en'
//})
- ? ? ? ?.useSanitizeValueStrategy('sanitizeParameters')
+ ? ? ? ?.useSanitizeValueStrategy('escapeParameters')
.uniformLanguageTag('bcp47')
.determinePreferredLanguage();
}])
2...es/flowable-ui-task/flowable-ui-task-app/src/main/webapp/workflow/scripts/workflow-app.js
@@ -112,7 +112,7 @@ flowableApp
//.registerAvailableLanguageKeys(['en'], {
//'en-*': 'en'
//})
- ? ? ? ?.useSanitizeValueStrategy('sanitizeParameters')
+ ? ? ? ?.useSanitizeValueStrategy('escapeParameters')
.uniformLanguageTag('bcp47')
.determinePreferredLanguage();