JAVA+Struts2 method to get the server address

  • 2020-04-01 03:33:37
  • OfStack

This article illustrates an example of how JAVA+Struts2 can get a server address. Share with you for your reference. The specific implementation method is as follows:

HttpServletRequest request=ServletActionContext.getRequest();  
String path=request.getRequestURI(); 
String actionPath=".."+path.substring(9); 
//Access to the server with parameter information & NBSP; < br / > String queryInfo=request.getQueryString(); 
if(queryInfo!=null&&(!queryInfo.equals(""))){ 
  actionPath=actionPath+"?"+queryInfo; 

logger.debug(" The user access path is :"+actionPath); 
ActionContext.getContext().getSession().put(GlobalField.PRE_PATH, actionPath);

I hope this article has been helpful to your Java programming.


Related articles: