我在jetty web服务器(还有tomcat)上运行基于注释的Spring Rest服务。控制器代码是:
\n\n@RequestMapping(method = RequestMethod.POST, value = { "/ssrfeed/exec/",\n "/query/exec" }, consumes = { "application/xml", "text/xml",\n "application/x-www-form-urlencoded" }, produces = {\n "application/xml;charset=UTF-8", "text/xml;charset=UTF-8",\n "application/x-www-form-urlencoded;charset=UTF-8" })\n @ResponseBody\n protected String getXmlFeed(HttpServletRequest request,\n @PathVariable String serviceName, @RequestBody String xmlReq) {\n\n //code....\n return appXMLResponse;\n }\nRun Code Online (Sandbox Code Playgroud)\n\n问题是控制器返回的响应 xml 包含一些字符,例如 \xc3\xa4 \xc3\xb6 \xc3\xbc (Umlaute)。在浏览器上呈现时的响应给出解析错误:
\n\nXML Parsing Error: not well-formed\nLocation: //localhost:8083/MySerice/ssrfeed/exec/\nLine Number 18111, Column 17:\n<FIRST_NAME>Tzee rfista</FIRST_NAME>\n----------------^\nRun Code Online (Sandbox Code Playgroud)\n\n(\xc3\xbc 的位置出现一个小三角形)
\n\nThe expected is : <FIRST_NAME>Tzee\xc3\xbcrfista</FIRST_NAME>\nRun Code Online (Sandbox Code Playgroud)\n\n我已尝试以下解决方案,但问题仍然存在。
\n\n尝试使用过滤器参考technowobble上给出的解决方案
将字符集传递给 …
想要了解处理Mapper/Reducer中的异常的最佳实践.
选项1:没有任何try/catch并让任务失败,MR将重试最终终止作业的任务.属性mapreduce.map/reduce.maxattempts在这里扮演角色.
选项2:使用计数器记录catch块中的故障数.并且基于这些错误的某些阈值,要么取消作业,要么只使用计数器来显示失败记录的数量.
在map-reduce中处理异常的任何(其他)通用/标准实践?