当前位置: 移动技术网 > IT编程>开发语言>Java > JAVA+Struts2获取服务器地址的方法

JAVA+Struts2获取服务器地址的方法

2019年07月22日  | 移动技术网IT编程  | 我要评论

本文实例讲述了java+struts2获取服务器地址的方法。分享给大家供大家参考。具体实现方法如下:

复制代码 代码如下:
httpservletrequest request=servletactioncontext.getrequest(); 
string path=request.getrequesturi(); 
string actionpath=".."+path.substring(9); 
//访问服务器所带有的参数信息 
string queryinfo=request.getquerystring(); 
if(queryinfo!=null&&(!queryinfo.equals(""))){ 
  actionpath=actionpath+"?"+queryinfo; 

logger.debug("用户访问的路径是:"+actionpath); 
actioncontext.getcontext().getsession().put(globalfield.pre_path, actionpath);

希望本文所述对大家的java程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网