Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ModelController.java #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LucienYang
Copy link

fix 使用activiti modeler设计的流程部署后中文乱码问题

fix 使用activiti modeler设计的流程部署后中文乱码问题
@yangqihua
Copy link

哥们,你这么做也是不对的,你的 bpmnBytes = new BpmnXMLConverter().convertToXML(model,"GBK");Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy(); 意思是以GBK的方式转换成byte数组,在deploy的时候,你的 new String(bpmnBytes) 没有传入转换成字符串的编码,意味着以系统默认的编码来转换(查看 new String([]byte) 源码可以看出),也就是说你以GBK的方式转换成byte数组,下一步却以系统默认的编码来转换成String,如果一旦系统默认编码不是GBK,你这种做法同样会导致乱码(你自己机器上没乱码是因为你很侥幸,你的机器的默认编码就是GBK)

@yangqihua
Copy link

正确的方式如下,只需将原来的
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
改成
Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes,"UTF-8")).deploy();
因为 bpmnBytes = new BpmnXMLConverter().convertToXML(model); 不传入指定编码的时候,会以UTF-8的格式去转换成byte数组(查看源码可以看到),所以在new String 的时候传入UTF-8去转换成字符串就不会乱码了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants