国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁(yè) > news >正文

上傳wordpress網(wǎng)站如何制作一個(gè)網(wǎng)頁(yè)

上傳wordpress網(wǎng)站,如何制作一個(gè)網(wǎng)頁(yè),國(guó)外企業(yè)網(wǎng)址,網(wǎng)站運(yùn)營(yíng)做seo一、不傳參數(shù)二、通過(guò) HttpServletRequest 獲取三、配置文件獲取四、ManagementFactory五、RequestContextHolder 1、不傳參數(shù),直接通過(guò)ServletRequestAttributes獲取當(dāng)前項(xiàng)目所在服務(wù)器的端口號(hào)和ip地址 public static String getUrl(){ ServletRequestAttrib…
  • 一、不傳參數(shù)
  • 二、通過(guò) HttpServletRequest 獲取
  • 三、配置文件獲取
  • 四、ManagementFactory
  • 五、RequestContextHolder

1、不傳參數(shù),直接通過(guò)ServletRequestAttributes獲取當(dāng)前項(xiàng)目所在服務(wù)器的端口號(hào)和ip地址

public static String getUrl(){    ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();    HttpServletRequest request = requestAttributes.getRequest();    String localAddr = request.getLocalAddr();    int serverPort = request.getServerPort();    return "http://"+localAddr +":"+ serverPort;
}

2、通過(guò) HttpServletRequest 傳參數(shù)獲取當(dāng)前項(xiàng)目所在服務(wù)器的端口號(hào)和ip地址

//獲取本地服務(wù)器的ip地址和端口號(hào)    
public static String getHttpUrl(HttpServletRequest request){        String localAddr = request.getLocalAddr();        int serverPort = request.getServerPort();        return "http://"+localAddr +":"+ serverPort;    
}

3、Java獲取當(dāng)前系統(tǒng)的ip地址,端口號(hào)從配置文件讀取

@Value("${server.port}")
private int serverPort; 
public String getUrl() {    InetAddress address = null;    try {        address = InetAddress.getLocalHost();    } catch (UnknownHostException e) {        e.printStackTrace();    }    return "http://"+address.getHostAddress() +":"+this.serverPort;
}

4、tomcat服務(wù)器啟動(dòng)到時(shí)候獲取服務(wù)器的ip和端口號(hào),本方法在windows系統(tǒng)沒(méi)問(wèn)題,再Linux系統(tǒng)就不行了

 //獲取本地服務(wù)器的ip地址和端口號(hào)
public static String getUrl() 
{        String serverIp = "";        String serverPort = "";        try {            MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();            Set<ObjectName> objectNames = beanServer.queryNames(new ObjectName("*:type=Connector,*"),             Query.match(Query.attr("protocol"), Query.value("HTTP/1.1")));            serverIp = InetAddress.getLocalHost().getHostAddress();            serverPort = objectNames.iterator().next().getKeyProperty("port");        } catch (Exception e) {            e.printStackTrace();        }        String ipAndPost = "http://" + serverIp + serverPort;        return ipAndPost;    
}

5、獲取服務(wù)器的ip+端口號(hào)

public static String PathAddress() {		String strResult = "";		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder				.getRequestAttributes()).getRequest(); 		StringBuffer strBuf = new StringBuffer();	strBuf.append(request.getScheme() + "://");		strBuf.append(request.getServerName() + ":");		strBuf.append(request.getServerPort() + "");		strBuf.append(request.getContextPath() + "/");		strResult = strBuf.toString();// +"FHADMINM/";//加入項(xiàng)目的名稱		return strResult;	
}
http://aloenet.com.cn/news/46287.html

相關(guān)文章:

  • 長(zhǎng)沙商城網(wǎng)站網(wǎng)絡(luò)營(yíng)銷策略都有哪些
  • 垃圾站 WordPress微商如何引流與推廣
  • 紅酒手機(jī)網(wǎng)站模板足球積分排行榜最新
  • 在沈陽(yáng)做一個(gè)展示網(wǎng)站多少錢google play商店
  • 網(wǎng)站服務(wù)器與虛擬主機(jī)百度知道合伙人
  • 營(yíng)銷型網(wǎng)站策劃公司seo外包優(yōu)化服務(wù)商
  • 把網(wǎng)站做app最有創(chuàng)意的廣告語(yǔ)30條
  • 移動(dòng)網(wǎng)站設(shè)計(jì)教程引擎搜索入口
  • 網(wǎng)站建設(shè)公司價(jià)位百度指數(shù)的需求指數(shù)
  • 谷歌上怎樣做網(wǎng)站網(wǎng)站seo什么意思
  • 外貿(mào)流程詢盤發(fā)盤seo168小視頻
  • 個(gè)人網(wǎng)站想添加支付功能怎么做seo優(yōu)
  • 陽(yáng)江市建設(shè)路龍?jiān)磳W(xué)校網(wǎng)站網(wǎng)站優(yōu)化推廣seo公司
  • 新媒體營(yíng)銷中常見(jiàn)的知識(shí)問(wèn)答平臺(tái)有seo網(wǎng)站有哪些
  • 張家港企業(yè)網(wǎng)站設(shè)計(jì)現(xiàn)在學(xué)seo課程多少錢
  • 平頂山做網(wǎng)站品牌公關(guān)具體要做些什么
  • 平臺(tái)和網(wǎng)站有什么區(qū)別網(wǎng)絡(luò)營(yíng)銷工資一般多少
  • 赤峰做網(wǎng)站公司百度地圖導(dǎo)航2021最新版
  • 哪些公司做網(wǎng)站開(kāi)發(fā)百度163黃頁(yè)關(guān)鍵詞挖掘
  • 敦化網(wǎng)站建設(shè)哈爾濱最新今日頭條新聞
  • 移動(dòng)互聯(lián)應(yīng)用技術(shù)微博搜索引擎優(yōu)化
  • 做網(wǎng)站幾個(gè)步驟seo外包優(yōu)化公司
  • 常州外貿(mào)網(wǎng)站建設(shè)我是新手如何做電商
  • 企業(yè)網(wǎng)站開(kāi)發(fā)多少錢沈陽(yáng)今天剛剛發(fā)生的新聞
  • 青島公司做網(wǎng)站鄭州seo顧問(wèn)培訓(xùn)
  • 高端的鎮(zhèn)江網(wǎng)站建設(shè)運(yùn)營(yíng)商大數(shù)據(jù)精準(zhǔn)營(yíng)銷
  • 自己做網(wǎng)站教學(xué)視頻重慶整站seo
  • 無(wú)錫網(wǎng)站怎么做站內(nèi)seo和站外seo區(qū)別
  • 想做一個(gè)網(wǎng)站平臺(tái)怎么做的廣告推廣系統(tǒng)
  • 廣州市專業(yè)做商城網(wǎng)站百度認(rèn)證官網(wǎng)