和谐的函数
wuhaixing
2011-12-06
http://stackoverflow.com/questions/2183503/substitute-values-in-a-string-with-placeholders-in-scala
本文所包含的代码不保证能编译通过 字符串替换问题 比如和谐,那就是说有一个字符串有些不和谐的词,希望得到一个和谐的字符串,得有个和谐的函数: (String, List[String]) => String 或者把那些个不和谐的词放在更合适的集合里: (String, IndexedSeq[String]) => String 大方向明确,工作分解,这个函数里面该做些什么呢? 基本上有三种方式:recursion, comprehension, folding recursion 递归的思路比较直白,就是搞明白第一步怎么做,然后对剩下的数据重复进行第一步操作。那和谐的问题解决办法就是: 1.替换第一个不和谐的词 2.替换剩下那些个不和谐的词 COMPREHENSION comprehension的基本概念就是利用函数A=>B把T[A]转化成T[B],比如用函数String => Int,输入List[String]得到一个List[Int],和谐的问题就是需要一个 (List[String], String => String) => String |
|
IT_caoruijun
2011-12-09
帮我看看以下是什么错误(ibatis的):
java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "SqlMap", must match DOCTYPE root "sqlMapConfig". at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49) at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63) at com.itcast.IStudentDAOmpl.<clinit>(IStudentDAOmpl.java:19) Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "SqlMap", must match DOCTYPE root "sqlMapConfig". at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46) ... 2 more Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "SqlMap", must match DOCTYPE root "sqlMapConfig". at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84) at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51) ... 3 more Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "SqlMap", must match DOCTYPE root "sqlMapConfig". at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53) at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40) at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270) at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121) ... 7 more Caused by: org.xml.sax.SAXParseException: Document root element "SqlMap", must match DOCTYPE root "sqlMapConfig". at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1652) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1931) at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:795) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:878) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(XMLDocumentScannerImpl.java:1157) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292) at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157) at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50) ... 10 more Exception in thread "main" |