问题描述
<?xmlversion="1.0"encoding="GBK"?><config><defaulthead="/theme/sm"foot="/theme/sm"><css></css><js></js><vars><title>sm</title><charset>GBK</charset><contentType>text/html</contentType></vars></default></config>
publicSiteConfiggetSiteConfig(Stringxml){SiteConfigsiteConfig=newSiteConfig();Digesterdigester=newDigester();//digester.push(this);digester.addObjectCreate("config",SiteConfig.class);digester.addBeanPropertySetter("config/domain");digester.addBeanPropertySetter("config/content");//digester.setValidating(false);digester.addObjectCreate("config/keyWords","keyWords",KeyWords.class);//digester.addBeanPropertySetter("config/keyWords");digester.addBeanPropertySetter("config/keyWords/alipayKey");digester.addBeanPropertySetter("config/keyWords/siteKey");digester.addBeanPropertySetter("config/keyWords/pageKey");//digester.addObjectCreate("config/Path",Path.class);digester.addObjectCreate("config/path","path",Path.class);digester.addBeanPropertySetter("config/path/cssPath");digester.addBeanPropertySetter("config/path/jsPath");try{siteConfig=(SiteConfig)digester.parse(newFile(xml));}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(SAXExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}returnsiteConfig;//问题是解析出来的这个对象的keyWords和path都是null,求指点啊}
publicclassSiteConfigimplementsSerializable{/****/privatestaticfinallongserialVersionUID=596887250467212782L;privateStringdomain;privateKeyWordskeyWords;privateStringcontent;privatePathpath;publicStringgetDomain(){returndomain;}publicvoidsetDomain(Stringdomain){this.domain=domain;}publicKeyWordsgetKeyWords(){returnkeyWords;}publicvoidsetKeyWords(KeyWordskeyWords){this.keyWords=keyWords;}publicStringgetContent(){returncontent;}publicvoidsetContent(Stringcontent){this.content=content;}publicPathgetPath(){returnpath;}publicvoidsetPath(Pathpath){this.path=path;}}publicclassKeyWordsimplementsSerializable{privatestaticfinallongserialVersionUID=-8668231831945261130L;privateStringalipayKey;privateStringsiteKey;privateStringpageKey;publicStringgetAlipayKey(){returnalipayKey;}publicvoidsetAlipayKey(StringalipayKey){this.alipayKey=alipayKey;}publicStringgetSiteKey(){returnsiteKey;}publicvoidsetSiteKey(StringsiteKey){this.siteKey=siteKey;}publicStringgetPageKey(){returnpageKey;}publicvoidsetPageKey(StringpageKey){this.pageKey=pageKey;}}publicclassPathimplementsSerializable{privatestaticfinallongserialVersionUID=7981949485904274001L;privateStringcssPath;privateStringjsPath;publicStringgetCssPath(){returncssPath;}publicvoidsetCssPath(StringcssPath){this.cssPath=cssPath;}publicStringgetJsPath(){returnjsPath;}publicvoidsetJsPath(StringjsPath){this.jsPath=jsPath;}}