1.获取应用程序的虚拟目录名称
String contextPath=this.getRequestCycle().getInfrastructure().getContextPath()
返回的字符串为“/app”
2.获取和jsp中对应的request和response对象
WebRequest request=this.getRequestCycle().getInfrastructure().getRequest();
WebResponse response=this.getRequestCycle.getInfrastructure().getResponse();
3.获取和jsp中对应的session对象
WebSession session=this.getRequestCycle().getInfrastructure().getRequest().getSession(false)
String contextPath=this.getRequestCycle().getInfrastructure().getContextPath()
返回的字符串为“/app”
2.获取和jsp中对应的request和response对象
WebRequest request=this.getRequestCycle().getInfrastructure().getRequest();
WebResponse response=this.getRequestCycle.getInfrastructure().getResponse();
3.获取和jsp中对应的session对象
WebSession session=this.getRequestCycle().getInfrastructure().getRequest().getSession(false)
本文介绍了如何在Web应用中使用特定方法获取虚拟目录名称、request/response对象及session对象的方法。通过示例代码展示了如何通过getRequestCycle()等方法实现这些功能。
5万+

被折叠的 条评论
为什么被折叠?



