JAVA+Struts2获取服务器地址的方法
作者:shichen2014 时间:2022-01-26 22:25:11
本文实例讲述了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程序设计有所帮助。
标签:JAVA,Struts2
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java字节码ByteBuddy使用及原理解析上
2023-08-23 19:33:05
![](https://img.aspxhome.com/file/2023/0/58290_0s.png)
java简单实现斗地主发牌功能
2023-06-18 16:22:44
![](https://img.aspxhome.com/file/2023/6/57506_0s.jpg)
JAVA及相关字符集编码问题研究分享
2022-05-16 20:33:08
Java IO流 文件传输基础
2023-08-24 13:27:11
![](https://img.aspxhome.com/file/2023/0/58070_0s.png)
SpringCloud hystrix断路器与局部降级全面介绍
2023-10-28 17:29:11
![](https://img.aspxhome.com/file/2023/1/58481_0s.png)
Java中Range函数的简单介绍
2023-10-18 05:33:35
![](https://img.aspxhome.com/file/2023/0/66970_0s.png)
Android开发中Toast显示消息的方法小结
2023-07-31 20:29:14
Java语言实现快速幂取模算法详解
2022-06-08 13:18:51
Java面试题冲刺第二十二天-- Nginx
2023-11-16 13:43:48
![](https://img.aspxhome.com/file/2023/6/58916_0s.png)
Spring Boot+Mybatis+Druid+PageHelper实现多数据源并分页的方法
2023-09-06 19:53:30
![](https://img.aspxhome.com/file/2023/9/65269_0s.png)
微信第三方登录Android实现代码
2023-07-27 08:05:49
![](https://img.aspxhome.com/file/2023/6/85986_0s.png)
Spring Boot+Shiro实现一个Http请求的Basic认证
2022-06-01 22:22:31
![](https://img.aspxhome.com/file/2023/5/61065_0s.png)
浅谈Java的两种多线程实现方式
2022-08-17 09:42:37
![](https://img.aspxhome.com/file/2023/9/67639_0s.jpg)
Maven属性与版本管理详细步骤分解
2023-11-15 14:38:45
![](https://img.aspxhome.com/file/2023/1/59531_0s.png)
java使用IO流对数组排序实例讲解
2023-09-04 02:24:19
java实现word文档转pdf并添加水印的方法详解
2023-05-26 02:59:18
![](https://img.aspxhome.com/file/2023/9/62139_0s.png)
C#计算字符串哈希值(MD5、SHA)的方法小结
2022-07-02 15:47:55
![](https://img.aspxhome.com/file/2023/8/68628_0s.png)
IDEA 单元测试报错:Class not found:xxxx springboot的解决
2022-05-11 01:11:02
![](https://img.aspxhome.com/file/2023/3/69663_0s.png)
@SpringBootTest 注解报红问题及解决
2022-08-14 23:24:51
![](https://img.aspxhome.com/file/2023/6/71016_0s.jpg)
javaWeb项目部署到阿里云服务器步骤详解
2023-11-07 05:21:36
![](https://img.aspxhome.com/file/2023/9/58909_0s.png)