Review the request of the commonly used methods

1, request.getScheme () returns the protocol currently used by the link; general application returns http; SSL return https;

2, the application program is as follows:

 

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    <base href="<%=basePath%>">

 


3, review the request of the commonly used methods:

request.getSchema () can return the protocol used by the current page, http or https;

request.getServerName () to return the name of the server where the current page;

request.getServerPort () Returns the port server can use the current page is located, it is 80;

request.getContextPath () can return the application name where the current page;

Guess you like

Origin www.cnblogs.com/walkingcamel/p/11084548.html