The method of java to get some information of the server (server address/relative path/port/project name)

request.getServletContext().getRealPath("/") Get the full path of the server where the project is located, such as: D:\Program Files\apache-tomcat-7.0.25\webapps\TestSytem\
request.getServletPath() Get the client request Path name, such as: /object/delObject
request.getServerName() Get the server address, such as: localhost
request.getServerPort() Get the server port, such as 8080
request.getContextPath() Get the project name, such as: TestSytem
request.getLocalAddr() Get Local address, such as: 127.0.0.1
request.getLocalName() Get the local IP mapping name, such as: localhost
request.getLocalPort() Get the local port, such as: 8090
request.getRealPath("/") Get the full path of the server where the project is located, Such as: D:\Program Files\apache-tomcat-7.0.25\webapps\TestSytem\
request.getRemoteAddr() Get the remote host address, such as: 127.0.0.1
request.getRemoteHost() Get the remote host, such as: 127.0.0.1
request .getRemotePort() Get the remote client port, such as: 3623
request.getRequestedSessionId() Get the ID of the session, such as: 823A6BACAC64FB114235CBFE85A46CAA
request.getRequestURI() Get the request path containing the project name, such as: /TestSytem/object/delObject
request.getRequestURL().toString() Get the full path of the request, Such as: http://localhost:8090/TestSytem/object/delObject

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325677771&siteId=291194637