第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在java中將xml解析為字符串以在sitemap.xml中給出優(yōu)先級值

在java中將xml解析為字符串以在sitemap.xml中給出優(yōu)先級值

肥皂起泡泡 2023-11-01 16:33:57
在我的網(wǎng)站根目錄中,java servlet 已準(zhǔn)備好 content/falcon/en/index 后的所有文件并創(chuàng)建 sitemap.xml  <url><loc>https://www.ded.com/</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.ded.com/eFNOL/eFNOL_Login?SO=01</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.ded.com/customerselfservice/CSSU</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.dede.com/claims/roadside-assistance/</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.dede.com/payments/</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.ded.com/insurance/</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url><url><loc>https://www.dede.com/home/</loc><lastmod>2019-08-29</lastmod><changefreq>weekly</changefreq><priority>0.9</priority></url>
查看完整描述

1 回答

?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個贊

您可以添加以下方法來設(shè)置優(yōu)先級:


public static String getPriority (String location){

    switch(countSlashes(location)){

        case 3: return "1";

        case 4: return "0.9";

        case 5: return "0.8";

        case 6: return "0.7";

        default: return "0.0"; //or whatever prio in default case

    }

}


//replace everything except '/' to get count of slashes easily

private static int countSlashes(String location) {

    return location.replaceAll("[^/]", "").length();

}

然后您可以getPriority從您的createXMLNode方法中調(diào)用,如下所示:


.....


String location = request.getScheme() + "://" + request.getServerName() + childPage.getPath();

locElementNode.setTextContent(location);

....


priorityElementNode.setTextContent(getPriority(location));


....


查看完整回答
反對 回復(fù) 2023-11-01
  • 1 回答
  • 0 關(guān)注
  • 177 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號