activiti工作流解決歷史批注中文亂碼


/**
 * 根據流程實例查詢流程的批注信息
 *
 * @param processInstanceId
 * @return
 */
private List<Comment> findCommentByProcessInstanceId(String processInstanceId) {
	return taskService.getProcessInstanceComments(processInstanceId);
}

默認獲取到的Comment是沒有getMessage()方法的,只有getFullMessage(),getFullMessage會跟隨部署的系統編碼,保存到數據庫中的bolb字段可能會出現亂碼,但是message字段不是亂碼,如果審批備注只是文字的話,可以直接取message字段的值。
查看源碼得知,CommentEntityImpl 實現了Comment類接口,既可以把Comment 轉換為CommentEntityImpl,直接用其中的getMessage()方法即可。

List<Comment> list = findCommentByProcessInstanceId(processInstanceId);
for (Comment commentEntity : list) {
 CommentEntityImpl comment = null;
 if(commentEntity instanceof CommentEntityImpl){
	 comment = (CommentEntityImpl)commentEntity;
 }
String message = comment.getMessage();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM