Knoage-6.x社区版(spagoBI升级版)在使用时发现Document不能保存中文字符。
TAG:Knowage汉化,SpagoBI汉化,Knowage中文版,Knowage中文乱码
如果想报表名或描述保存为中文时会发生如下错误:
提示错误:
ERRORS: The field Description must be an alphanumeric string (letters and numbers with other character such as parenthesis and -_;:!?,.//)
只能输入字母数字及某些特殊字符的组合。
查询源代码:
9016 = The field %0 must be an alphanumeric string (letters and numbers with other character such as parenthesis and -_;:!?,./) ERROR_EXTENDED_ALFANUMERIC="9016";
页面代码:
knowage/src/main/webapp/WEB-INF/conf/analiticalmodel/documentBrowser.xml
验证规则:
knowage/src/main/webapp/WEB-INF/conf/analiticalmodel/validation.xml
重置验证:
<FIELD name="name" label="#SBIDev.docConf.docDet.nameField"> <VALIDATOR validatorName="MANDATORY"/> <!-- <VALIDATOR validatorName="EXTENDED_ALFANUMERIC"/> ranying --> <VALIDATOR validatorName="MAXLENGTH" arg0="200"/> </FIELD> <FIELD name="description" label="#SBIDev.docConf.docDet.descriptionField"> <!-- <VALIDATOR validatorName="EXTENDED_ALFANUMERIC"/> ranying --> <VALIDATOR validatorName="MAXLENGTH" arg0="400"/> </FIELD>
重置之后可以保存了但内容是乱码:
跟踪代码发现在验证之前就已经是乱码了,
请求链路:
1.it.eng.spago.dispatching.httpchannel.AdapterHTTP
问题就在handleMultipartForm方法,原因是使用common-fileupload解析字段内容但使用的默认编码格式,改为使用UTF-8格式读取字段内容。
private void handleMultipartForm(HttpServletRequest request, RequestContextIFace requestContext) throws Exception{ SourceBean serviceRequest = requestContext.getServiceRequest(); // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // This is done to make upload work in Unix solaris //((DiskFileItemFactory)factory).setSizeThreshold(5242880); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); //upload.setFileSizeMax(5242880); //upload.setSizeMax(5242880); // Parse the request List fileItems = upload.parseRequest(request); Iterator iter = fileItems.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { String name = item.getFieldName(); // Support all characters . by ranying String value = item.getString("utf-8"); serviceRequest.setAttribute(name, value); } else { processFileField(item, requestContext); } } }
修改之后可以正常保存中文名及描述了,Label建议保持只支持英文数字格式。